refactoring

This commit is contained in:
Jaremy Creechley 2024-02-12 13:48:20 -07:00
parent 889a8267c3
commit 3727c4855b
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 7 additions and 0 deletions

View File

@ -70,3 +70,8 @@ macro submitMacro*(tp: untyped, jobs: untyped, exp: untyped): untyped =
template submit*[T](jobs: JobQueue[T], exp: untyped): Future[T] =
submitMacro(T, jobs, exp)
template jobWrapper*(task: untyped) =
template `task Wrapper`*(jobResult: JobResult[float], args: varargs[untyped]) =
let res = unpackVarargs(`task`(args))
discard jobResult.queue.send((jobResult.id, res,))

View File

@ -20,6 +20,8 @@ proc addNums(jobResult: JobResult[float], a, b: float) =
let res = addNumsRaw(a, b)
discard jobResult.queue.send((jobResult.id, res,))
jobWrapper(addNumsRaw)
suite "async tests":
# var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.