annotate Implab.Test/PromiseHelper.cs @ 33:b255e4aeef17

removed the reference to the parent from the promise object this allows resolved promises to release parents and results they are holding. Added complete set of operations to IPromiseBase interface Subscribing to the cancellation event of the promise should not affect it's IsExclusive property More tests.
author cin
date Thu, 10 Apr 2014 02:39:29 +0400
parents 6ec82bf68c8e
children 3b8393be3441
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
6ec82bf68c8e refactoring
cin
parents: 10
diff changeset
1 using Implab.Parallels;
6ec82bf68c8e refactoring
cin
parents: 10
diff changeset
2 using System;
10
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
3 using System.Collections.Generic;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
4 using System.Linq;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
5 using System.Text;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
6 using System.Threading;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
7
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
8 namespace Implab.Test {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
9 class PromiseHelper {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
10 public static Promise<T> Sleep<T>(int timeout, T retVal) {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
11 return AsyncPool.Invoke(() => {
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
12 Thread.Sleep(timeout);
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
13 return retVal;
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
14 });
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
15 }
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
16 }
aa33d0bb8c0c implemeted new cancellable promises concept
cin
parents:
diff changeset
17 }