diff options
author | Yuriy Glukhov <yglukhov@users.noreply.github.com> | 2017-07-14 09:15:37 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-07-14 08:15:37 +0200 |
commit | 8bdcade1a08306ccf17c719838a97427a43a112c (patch) | |
tree | 44459978cc04a286047eb4b8c0de10fa2b3f5621 /lib/pure/concurrency | |
parent | 52cab78ae57b5a36c7e05c41fa23a55b8302b2ee (diff) | |
download | Nim-8bdcade1a08306ccf17c719838a97427a43a112c.tar.gz |
Fixes #6090 (#6092)
Diffstat (limited to 'lib/pure/concurrency')
-rw-r--r-- | lib/pure/concurrency/threadpool.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim index f438a85e7..cf4f58588 100644 --- a/lib/pure/concurrency/threadpool.nim +++ b/lib/pure/concurrency/threadpool.nim @@ -530,6 +530,7 @@ proc nimSpawn4(fn: WorkerProc; data: pointer; id: ThreadId) {.compilerProc.} = proc sync*() = ## a simple barrier to wait for all spawn'ed tasks. If you need more elaborate ## waiting, you have to use an explicit barrier. + var toRelease = 0 while true: var allReady = true for i in 0 .. <currentPoolSize: @@ -537,5 +538,9 @@ proc sync*() = allReady = allReady and workersData[i].ready if allReady: break await(gSomeReady) + inc toRelease + + for i in 0 ..< toRelease: + signal(gSomeReady) setup() |