mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-03 13:33:08 +00:00
logging
This commit is contained in:
parent
17576f94e2
commit
797c9824ea
@ -13,7 +13,6 @@ import apatheia/tasks
|
||||
|
||||
proc addNums(a, b: float): float {.asyncTask.} =
|
||||
os.sleep(100)
|
||||
# info "adding: ", a=a, b=b
|
||||
return a + b
|
||||
|
||||
proc addNumValues(vals: openArray[float]): float {.asyncTask.} =
|
||||
@ -21,22 +20,17 @@ proc addNumValues(vals: openArray[float]): float {.asyncTask.} =
|
||||
result = 0.0
|
||||
for x in vals:
|
||||
result += x
|
||||
# echo "adding sums: ", vals
|
||||
|
||||
suite "async tests":
|
||||
var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.
|
||||
|
||||
asyncTest "test addNums":
|
||||
var jobs = newJobQueue[float](taskpool = tp)
|
||||
echo "\nstart"
|
||||
let res = await jobs.submit(addNums(1.0, 2.0,))
|
||||
echo "result: ", res.repr
|
||||
check true
|
||||
check res == 3.0
|
||||
|
||||
asyncTest "test addNumValues":
|
||||
var jobs = newJobQueue[float](taskpool = tp)
|
||||
echo "\nstart"
|
||||
let args = @[1.0, 2.0, 3.0]
|
||||
let res = await jobs.submit(addNumValues(args))
|
||||
echo "result: ", res.repr
|
||||
check true
|
||||
check res == 6.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user