From 06e9932e8ae6860b1c96c57138d2d56e51f7036d Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 7 Nov 2014 01:54:47 +0100 Subject: fixes exhaustion bug and missing GC_ref code generation --- lib/pure/concurrency/threadpool.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/pure') diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index 727bbffa2..7959a6c92 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -100,7 +100,8 @@ type # for 'awaitAny' support ai: ptr AwaitInfo idx: int - data: RootRef # we incRef and unref it to keep it alive + data: pointer # we incRef and unref it to keep it alive; note this MUST NOT + # be RootRef here otherwise the wrong GC keeps track of it! owner: pointer # ptr Worker FlowVarObj[T] = object of FlowVarBaseObj @@ -162,10 +163,8 @@ proc finished(fv: FlowVarBase) = var waited = false acquire(q.lock) while not (q.len < q.data.len): - echo "EXHAUSTED!" - release(q.lock) + #echo "EXHAUSTED!" wakeupWorkerToProcessQueue(owner) - acquire(q.lock) wait(q.empty, q.lock) waited = true q.data[q.len] = cast[pointer](fv.data) @@ -180,7 +179,7 @@ proc cleanFlowVars(w: ptr Worker) = acquire(q.lock) for i in 0 ..