mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
This reverts commit bdb653c415.
This commit is contained in:
committed by
Andreas Rumpf
parent
733272d55d
commit
30e2af969c
@@ -526,12 +526,10 @@ proc nimSpawn4(fn: WorkerProc; data: pointer; id: ThreadId) {.compilerProc.} =
|
||||
if selectWorker(addr(distinguishedData[id]), fn, data): break
|
||||
await(distinguishedData[id].readyForTask)
|
||||
|
||||
template spawnInAllThreads(e: untyped) =
|
||||
## Spawn `e` on all of the threadpool threads.
|
||||
for i in 0 .. <currentPoolSize:
|
||||
pinnedSpawn(i, e)
|
||||
|
||||
proc syncAux() {.inline.} =
|
||||
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
|
||||
@@ -545,12 +543,4 @@ proc syncAux() {.inline.} =
|
||||
for i in 0 ..< toRelease:
|
||||
signal(gSomeReady)
|
||||
|
||||
proc sync*(cleanup: bool = true) =
|
||||
## A simple barrier to wait for all spawn'ed tasks. Calls `GC_fullCollect()`
|
||||
## on all threads if `cleanup` is `true`. If you need more elaborate
|
||||
## waiting, you have to use an explicit barrier.
|
||||
syncAux()
|
||||
if cleanup:
|
||||
spawnInAllThreads GC_fullCollect()
|
||||
|
||||
setup()
|
||||
|
||||
Reference in New Issue
Block a user