Mercurial > pub > ImplabNet
comparison Implab.Test/AsyncTests.cs @ 20:1c3b3d518480 promises
refactoring, sync
author | cin |
---|---|
date | Tue, 12 Nov 2013 02:27:22 +0400 |
parents | e3935fdf59a2 |
children | 6a56df4ec59e |
comparison
equal
deleted
inserted
replaced
19:e3935fdf59a2 | 20:1c3b3d518480 |
---|---|
99 | 99 |
100 [TestMethod] | 100 [TestMethod] |
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.ThreadCount); | 104 Assert.AreEqual(5, pool.PoolSize); |
105 | 105 |
106 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); | 106 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); |
107 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); | 107 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); |
108 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); | 108 pool.Invoke(() => { Thread.Sleep(1000000); return 10; }); |
109 | 109 |
110 Assert.AreEqual(5, pool.ThreadCount); | 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(1000000); return 10; }); |
114 Thread.Sleep(100); | 114 Thread.Sleep(100); |
115 Assert.AreEqual(10, pool.ThreadCount); | 115 Assert.AreEqual(10, pool.PoolSize); |
116 | 116 |
117 pool.Dispose(); | 117 pool.Dispose(); |
118 } | 118 } |
119 | 119 |
120 [TestMethod] | 120 [TestMethod] |
147 } | 147 } |
148 | 148 |
149 [TestMethod] | 149 [TestMethod] |
150 public void WorkerPoolDisposeTest() { | 150 public void WorkerPoolDisposeTest() { |
151 var pool = new WorkerPool(5, 20); | 151 var pool = new WorkerPool(5, 20); |
152 Assert.AreEqual(5, pool.ThreadCount); | 152 Assert.AreEqual(5, pool.PoolSize); |
153 pool.Dispose(); | 153 pool.Dispose(); |
154 Thread.Sleep(100); | 154 Thread.Sleep(200); |
155 Assert.AreEqual(0, pool.ThreadCount); | 155 Assert.AreEqual(0, pool.PoolSize); |
156 pool.Dispose(); | 156 pool.Dispose(); |
157 } | 157 } |
158 | 158 |
159 [TestMethod] | 159 [TestMethod] |
160 public void MTQueueTest() { | 160 public void MTQueueTest() { |
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 |