comparison Implab.Test/AsyncTests.cs @ 24:ee04e1fa78da

fixed dispatch pool race condition
author cin
date Thu, 14 Nov 2013 01:15:07 +0400
parents 5a35900264f5
children 2fad2d1f4b03
comparison
equal deleted inserted replaced
23:f0568ff069a5 24:ee04e1fa78da
242 } 242 }
243 243
244 [TestMethod] 244 [TestMethod]
245 public void ChainedMapTest() { 245 public void ChainedMapTest() {
246 246
247 using (var pool = new WorkerPool(4,4,0)) { 247 using (var pool = new WorkerPool(0,100,0)) {
248 int count = 10000; 248 int count = 10000;
249 249
250 double[] args = new double[count]; 250 double[] args = new double[count];
251 var rand = new Random(); 251 var rand = new Random();
252 252
253 for (int i = 0; i < count; i++) 253 for (int i = 0; i < count; i++)
254 args[i] = rand.NextDouble(); 254 args[i] = rand.NextDouble();
255 255
256 var t = Environment.TickCount; 256 var t = Environment.TickCount;
257 var res = args 257 var res = args
258 .ChainedMap( 258 .ChainedMap2(
259 x => pool.Invoke( 259 x => pool.Invoke(
260 () => Math.Sin(x * x) 260 () => Math.Sin(x * x)
261 ), 261 ),
262 4 262 4
263 ) 263 )