diff Implab/Parallels/WorkerPool.cs @ 20:1c3b3d518480 promises

refactoring, sync
author cin
date Tue, 12 Nov 2013 02:27:22 +0400
parents 7cd4a843b4e4
children 6a56df4ec59e
line wrap: on
line diff
--- a/Implab/Parallels/WorkerPool.cs	Sun Nov 10 00:21:33 2013 +0400
+++ b/Implab/Parallels/WorkerPool.cs	Tue Nov 12 02:27:22 2013 +0400
@@ -57,12 +57,11 @@
             var len = Interlocked.Increment(ref m_queueLength);
             m_queue.Enqueue(unit);
 
-            if(!ExtendPool())
-                WakePool();
+            ExtendPool();
         }
 
         protected override bool ExtendPool() {
-            if (m_queueLength <= m_threshold*ThreadCount)
+            if (m_queueLength <= m_threshold*ActiveThreads)
                 // in this case we are in active thread and it request for additional workers
                 // satisfy it only when queue is longer than threshold
                 return false;
@@ -81,9 +80,11 @@
             unit();
         }
 
-        protected override void Suspend() {
+        protected override bool Suspend() {
             if (m_queueLength == 0)
-                base.Suspend();
+                return base.Suspend();
+            else
+                return true; // spin again without locks...
         }
     }
 }