mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-04 05:53:11 +00:00
docs
This commit is contained in:
parent
b7ddb871fe
commit
87d85a3425
@ -54,6 +54,7 @@ proc processJobs*[T](jobs: JobQueue[T]) {.async.} =
|
|||||||
info "Finishing processing jobs for type ", type=tn
|
info "Finishing processing jobs for type ", type=tn
|
||||||
|
|
||||||
proc createFuture*[T](jobs: JobQueue[T], name: static string): (JobResult[T], Future[T]) =
|
proc createFuture*[T](jobs: JobQueue[T], name: static string): (JobResult[T], Future[T]) =
|
||||||
|
## Creates a future that returns the result of the associated job.
|
||||||
let fut = newFuture[T](name)
|
let fut = newFuture[T](name)
|
||||||
let id = JobId fut.id()
|
let id = JobId fut.id()
|
||||||
jobs.futures[id] = fut
|
jobs.futures[id] = fut
|
||||||
@ -61,6 +62,7 @@ proc createFuture*[T](jobs: JobQueue[T], name: static string): (JobResult[T], Fu
|
|||||||
return (JobResult[T](id: id, queue: jobs.queue), fut, )
|
return (JobResult[T](id: id, queue: jobs.queue), fut, )
|
||||||
|
|
||||||
proc newJobQueue*[T](maxItems: int = 0, taskpool: Taskpool = Taskpool.new()): JobQueue[T] {.raises: [ApatheiaSignalErr].} =
|
proc newJobQueue*[T](maxItems: int = 0, taskpool: Taskpool = Taskpool.new()): JobQueue[T] {.raises: [ApatheiaSignalErr].} =
|
||||||
|
## Creates a new async-compatible threaded job queue.
|
||||||
result = JobQueue[T](queue: newSignalQueue[(uint, T)](maxItems), taskpool: taskpool, running: true)
|
result = JobQueue[T](queue: newSignalQueue[(uint, T)](maxItems), taskpool: taskpool, running: true)
|
||||||
asyncSpawn(processJobs(result))
|
asyncSpawn(processJobs(result))
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user