Merge pull request #3437 from nim-lang/threadpool-isready
Implement isReady procedure in threadpool module.
This commit is contained in:
commit
612d3f84fb
1 changed files with 11 additions and 0 deletions
|
|
@ -267,6 +267,17 @@ proc awaitAny*(flowVars: openArray[FlowVarBase]): int =
|
||||||
result = -1
|
result = -1
|
||||||
destroySemaphore(ai.cv)
|
destroySemaphore(ai.cv)
|
||||||
|
|
||||||
|
proc isReady*(fv: FlowVarBase): bool =
|
||||||
|
## Determines whether the specified ``FlowVarBase``'s value is available.
|
||||||
|
##
|
||||||
|
## If ``true`` awaiting ``fv`` will not block.
|
||||||
|
if fv.usesSemaphore and not fv.awaited:
|
||||||
|
acquire(fv.cv.L)
|
||||||
|
result = fv.cv.counter > 0
|
||||||
|
release(fv.cv.L)
|
||||||
|
else:
|
||||||
|
result = true
|
||||||
|
|
||||||
proc nimArgsPassingDone(p: pointer) {.compilerProc.} =
|
proc nimArgsPassingDone(p: pointer) {.compilerProc.} =
|
||||||
let w = cast[ptr Worker](p)
|
let w = cast[ptr Worker](p)
|
||||||
signal(w.taskStarted)
|
signal(w.taskStarted)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue