mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-02 13:03:11 +00:00
simple (wrong) example
This commit is contained in:
parent
06640c37de
commit
e2fb9582d2
@ -11,11 +11,23 @@ type
|
||||
ThreadArg = object
|
||||
startSig: ThreadSignalPtr
|
||||
doneSig: ThreadSignalPtr
|
||||
value: int
|
||||
value: float
|
||||
|
||||
proc addNums(a, b: float, ret: ptr float) =
|
||||
ret[] = a + b
|
||||
|
||||
suite "async tests":
|
||||
|
||||
var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.
|
||||
|
||||
asyncTest "test":
|
||||
var args = ThreadArg()
|
||||
args.startSig = ThreadSignalPtr.new().get()
|
||||
args.doneSig = ThreadSignalPtr.new().get()
|
||||
|
||||
tp.spawn addNums(1, 2, addr args.value)
|
||||
await sleepAsync(100.milliseconds)
|
||||
echo "\nRES: ", args.value
|
||||
|
||||
check true
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user