mirror of
https://github.com/logos-storage/nim-datastore.git
synced 2026-01-03 22:23:10 +00:00
add nextSignal using mutex
This commit is contained in:
parent
1fd80c6f2b
commit
c51d354f72
@ -41,6 +41,7 @@ type
|
||||
signal: ThreadSignalPtr
|
||||
running: bool ## used to mark when a task worker is running
|
||||
cancelled: bool ## used to cancel a task before it's started
|
||||
nextSignal: (Lock, Cond)
|
||||
|
||||
TaskCtx*[T] = SharedPtr[TaskCtxObj[T]]
|
||||
## Task context object.
|
||||
@ -72,6 +73,13 @@ proc setDone[T](ctx: TaskCtx[T]) =
|
||||
# withLock(ctxLock):
|
||||
ctx[].running = false
|
||||
|
||||
proc waitSync*(sig: var (Lock, Cond)) =
|
||||
withLock(sig[0]):
|
||||
wait(sig[1], sig[0])
|
||||
proc fireSync*(sig: var (Lock, Cond)) =
|
||||
withLock(sig[0]):
|
||||
signal(sig[1])
|
||||
|
||||
proc acquireSignal(): ?!ThreadSignalPtr =
|
||||
let signal = ThreadSignalPtr.new()
|
||||
if signal.isErr():
|
||||
|
||||
@ -24,7 +24,7 @@ import ./querycommontests
|
||||
|
||||
const
|
||||
NumThreads = 20 # IO threads aren't attached to CPU count
|
||||
ThreadTestLoops {.intdefine.} = 10
|
||||
ThreadTestLoops {.intdefine.} = 100
|
||||
N = ThreadTestLoops
|
||||
|
||||
for i in 1..N:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user