comparison Implab/Parallels/AsyncPool.cs @ 124:a336cb13c6a9 v2

major update, added Drain mathod to AsyncQueue class
author cin
date Thu, 15 Jan 2015 02:43:14 +0300
parents 62d2f1e98c4e
children 706fccb85524
comparison
equal deleted inserted replaced
123:f4d6ea6969cc 124:a336cb13c6a9
29 }); 29 });
30 30
31 return p; 31 return p;
32 } 32 }
33 33
34 public static IPromise<T> InvokeNewThread<T>(Func<T> func) { 34 public static IPromise<T> RunThread<T>(Func<T> func) {
35 var p = new Promise<T>(); 35 var p = new Promise<T>();
36 36
37 var caller = TraceContext.Instance.CurrentOperation; 37 var caller = TraceContext.Instance.CurrentOperation;
38 38
39 var worker = new Thread(() => { 39 var worker = new Thread(() => {
51 51
52 return p; 52 return p;
53 } 53 }
54 54
55 55
56 public static IPromise InvokeNewThread(Action func) { 56 public static IPromise RunThread(Action func) {
57 var p = new Promise(); 57 var p = new Promise();
58 58
59 var caller = TraceContext.Instance.CurrentOperation; 59 var caller = TraceContext.Instance.CurrentOperation;
60 60
61 var worker = new Thread(() => { 61 var worker = new Thread(() => {
74 74
75 return p; 75 return p;
76 } 76 }
77 77
78 public static IPromise[] RunThread(params Action[] func) { 78 public static IPromise[] RunThread(params Action[] func) {
79 return func.Select(f => InvokeNewThread(f)).ToArray(); 79 return func.Select(f => RunThread(f)).ToArray();
80 } 80 }
81 81
82 public static IPromise<T>[] RunThread<T>(params Func<T>[] func) { 82 public static IPromise<T>[] RunThread<T>(params Func<T>[] func) {
83 return func.Select(f => InvokeNewThread(f)).ToArray(); 83 return func.Select(f => RunThread(f)).ToArray();
84 } 84 }
85 } 85 }
86 } 86 }