@@ -244,7 +244,7 namespace Implab.Test { | |||
|
244 | 244 | [TestMethod] |
|
245 | 245 | public void ChainedMapTest() { |
|
246 | 246 | |
|
247 | using (var pool = new WorkerPool(0,100,0)) { | |
|
247 | using (var pool = new WorkerPool(0,100,100)) { | |
|
248 | 248 | int count = 10000; |
|
249 | 249 | |
|
250 | 250 | double[] args = new double[count]; |
|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -155,7 +155,7 namespace Implab.Parallels { | |||
|
155 | 155 | } |
|
156 | 156 | } |
|
157 | 157 | |
|
158 |
pr |
|
|
158 | protected void EnsurePoolIsAlive() { | |
|
159 | 159 | if (AllocateThreadSlot(1)) { |
|
160 | 160 | // if there were no threads in the pool |
|
161 | 161 | var worker = new Thread(this.Worker); |
@@ -164,7 +164,7 namespace Implab.Parallels { | |||
|
164 | 164 | } |
|
165 | 165 | } |
|
166 | 166 | |
|
167 |
pr |
|
|
167 | protected virtual bool Suspend() { | |
|
168 | 168 | //no tasks left, exit if the thread is no longer needed |
|
169 | 169 | bool last; |
|
170 | 170 | bool requestExit; |
@@ -295,7 +295,6 namespace Implab.Parallels { | |||
|
295 | 295 | InvokeUnit(unit); |
|
296 | 296 | continue; |
|
297 | 297 | } |
|
298 | ||
|
299 | 298 | Interlocked.Decrement(ref m_activeThreads); |
|
300 | 299 | |
|
301 | 300 | // entering suspend state |
@@ -69,6 +69,22 namespace Implab.Parallels { | |||
|
69 | 69 | return false; |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | protected override bool Suspend() { | |
|
73 | // This override solves race condition | |
|
74 | // WORKER CLIENT | |
|
75 | // --------------------------------------- | |
|
76 | // TryDeque == false | |
|
77 | // Enqueue(unit), queueLen++ | |
|
78 | // GrowPool? == NO | |
|
79 | // ActiveThreads-- | |
|
80 | // Suspend | |
|
81 | // queueLength > 0 | |
|
82 | // continue | |
|
83 | if (m_queueLength > 0) | |
|
84 | return true; | |
|
85 | return base.Suspend(); | |
|
86 | } | |
|
87 | ||
|
72 | 88 | protected override void InvokeUnit(Action unit) { |
|
73 | 89 | unit(); |
|
74 | 90 | } |
General Comments 0
You need to be logged in to leave comments.
Login now