comparison Implab/Parallels/ArrayTraits.cs @ 23:f0568ff069a5

Слияние с promises
author cin
date Wed, 13 Nov 2013 14:03:20 +0400
parents e3935fdf59a2
children ee04e1fa78da
comparison
equal deleted inserted replaced
18:0c924dff5498 23:f0568ff069a5
138 var pending = source.Length; 138 var pending = source.Length;
139 var semaphore = new Semaphore(threads, threads); 139 var semaphore = new Semaphore(threads, threads);
140 140
141 AsyncPool.InvokeNewThread(() => { 141 AsyncPool.InvokeNewThread(() => {
142 for (int i = 0; i < source.Length; i++) { 142 for (int i = 0; i < source.Length; i++) {
143 if(promise.State != PromiseState.Unresolved) 143 if(promise.IsResolved)
144 break; // stop processing in case of error or cancellation 144 break; // stop processing in case of error or cancellation
145 var idx = i; 145 var idx = i;
146 semaphore.WaitOne(); 146 semaphore.WaitOne();
147 try { 147 try {
148 var p1 = transform(source[i]); 148 var p1 = transform(source[i]);