Mercurial > pub > ImplabNet
diff Implab/Parallels/ArrayTraits.cs @ 30:2fad2d1f4b03
small refactoring, cleanup.
author | cin |
---|---|
date | Mon, 07 Apr 2014 03:25:57 +0400 |
parents | f0bf98e4d22c |
children | 8eca2652d2ff |
line wrap: on
line diff
--- a/Implab/Parallels/ArrayTraits.cs Thu Mar 06 17:59:03 2014 +0400 +++ b/Implab/Parallels/ArrayTraits.cs Mon Apr 07 03:25:57 2014 +0400 @@ -105,7 +105,7 @@ } } - public static Promise<TDst[]> ParallelMap<TSrc, TDst> (this TSrc[] source, Func<TSrc,TDst> transform, int threads) { + public static IPromise<TDst[]> ParallelMap<TSrc, TDst> (this TSrc[] source, Func<TSrc,TDst> transform, int threads) { if (source == null) throw new ArgumentNullException("source"); if (transform == null) @@ -115,7 +115,7 @@ return mapper.Promise; } - public static Promise<int> ParallelForEach<TSrc>(this TSrc[] source, Action<TSrc> action, int threads) { + public static IPromise<int> ParallelForEach<TSrc>(this TSrc[] source, Action<TSrc> action, int threads) { if (source == null) throw new ArgumentNullException("source"); if (action == null) @@ -136,6 +136,7 @@ var promise = new Promise<TDst[]>(); var res = new TDst[source.Length]; var pending = source.Length; + var semaphore = new Semaphore(threads, threads); AsyncPool.InvokeNewThread(() => {