comparison Implab.Test/AsyncTests.cs @ 22:5a35900264f5 promises

implemented nonblocking wake singnals processing
author cin
date Wed, 13 Nov 2013 14:03:00 +0400
parents 6a56df4ec59e
children ee04e1fa78da
comparison
equal deleted inserted replaced
21:6a56df4ec59e 22:5a35900264f5
101 public void WorkerPoolSizeTest() { 101 public void WorkerPoolSizeTest() {
102 var pool = new WorkerPool(5, 10, 0); 102 var pool = new WorkerPool(5, 10, 0);
103 103
104 Assert.AreEqual(5, pool.PoolSize); 104 Assert.AreEqual(5, pool.PoolSize);
105 105
106 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); 106 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
107 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); 107 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
108 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); 108 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
109 109
110 Assert.AreEqual(5, pool.PoolSize); 110 Assert.AreEqual(5, pool.PoolSize);
111 111
112 for (int i = 0; i < 100; i++) 112 for (int i = 0; i < 100; i++)
113 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); 113 pool.Invoke(() => { Thread.Sleep(100000000); return 10; });
114 Thread.Sleep(100); 114 Thread.Sleep(200);
115 Assert.AreEqual(10, pool.PoolSize); 115 Assert.AreEqual(10, pool.PoolSize);
116 116
117 pool.Dispose(); 117 pool.Dispose();
118 } 118 }
119 119
242 } 242 }
243 243
244 [TestMethod] 244 [TestMethod]
245 public void ChainedMapTest() { 245 public void ChainedMapTest() {
246 246
247 using (var pool = new WorkerPool(0,100,1)) { 247 using (var pool = new WorkerPool(4,4,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