annotate Implab.Test/PromiseHelper.cs @ 19:e3935fdf59a2 promises

Promise is rewritten to use interlocked operations instead of locks
author cin
date Sun, 10 Nov 2013 00:21:33 +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 }