mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-02 13:03:11 +00:00
setup jobs
This commit is contained in:
parent
25170e9bb2
commit
8a36e252fa
@ -17,6 +17,6 @@ type
|
||||
proc newJobQueue*[T](maxItems: int = 0, taskpool: Taskpool = Taskpool.new()): JobQueue[T] {.raises: [ApatheiaSignalErr].} =
|
||||
JobQueue[T](queue: newSignalQueue[T](maxItems), taskpool: taskpool)
|
||||
|
||||
template awaitJob*[T](jobs: JobQueue[T], exp: typed): auto =
|
||||
template submit*[T](jobs: JobQueue[T], exp: typed): Future[T] =
|
||||
jobs.taskpool.spawn(exp)
|
||||
await wait(jobs.queue)
|
||||
|
||||
@ -29,7 +29,7 @@ suite "async tests":
|
||||
asyncTest "test":
|
||||
|
||||
echo "\nstart"
|
||||
let res = jobs.awaitJob(addNums(jobs.queue, 1.0, 2.0)).get()
|
||||
let res = await jobs.submit(addNums(jobs.queue, 1.0, 2.0))
|
||||
|
||||
# await sleepAsync(100.milliseconds)
|
||||
echo "result: ", res.repr
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user