comparison Implab/Parallels/WorkerPool.cs @ 34:dabf79fde388

fixed race condition in DispatchPool
author cin
date Thu, 10 Apr 2014 04:20:25 +0400
parents 6a56df4ec59e
children 2880242f987a
comparison
equal deleted inserted replaced
33:b255e4aeef17 34:dabf79fde388
67 return true; 67 return true;
68 } 68 }
69 return false; 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 protected override void InvokeUnit(Action unit) { 88 protected override void InvokeUnit(Action unit) {
73 unit(); 89 unit();
74 } 90 }
75 91
76 } 92 }