comparison Implab/Parallels/AsyncPool.cs @ 120:f1b897999260 v2

improved asyncpool usability working on batch operations on asyncqueue
author cin
date Mon, 12 Jan 2015 05:19:52 +0300
parents 2573b562e328
children 62d2f1e98c4e
comparison
equal deleted inserted replaced
119:2573b562e328 120:f1b897999260
1 using Implab.Diagnostics; 1 using Implab.Diagnostics;
2 using System; 2 using System;
3 using System.Threading; 3 using System.Threading;
4 using System.Linq;
4 5
5 namespace Implab.Parallels { 6 namespace Implab.Parallels {
6 /// <summary> 7 /// <summary>
7 /// Класс для распаралеливания задач. 8 /// Класс для распаралеливания задач.
8 /// </summary> 9 /// </summary>
71 worker.IsBackground = true; 72 worker.IsBackground = true;
72 worker.Start(); 73 worker.Start();
73 74
74 return p; 75 return p;
75 } 76 }
77
78 public static IPromise[] ThreadRun(params Action[] func) {
79 return func.Select(f => InvokeNewThread(f)).ToArray();
80 }
81
82 public static IPromise<T>[] ThreadRun<T>(params Func<T>[] func) {
83 return func.Select(f => InvokeNewThread(f)).ToArray();
84 }
76 } 85 }
77 } 86 }