mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-07 15:33:09 +00:00
rename
This commit is contained in:
parent
f052987963
commit
903152b0b2
@ -43,7 +43,7 @@ template toOpenArray*[T](arr: OpenArrayHolder[T]): auto =
|
|||||||
func jobId*[T](fut: Future[T]): JobId =
|
func jobId*[T](fut: Future[T]): JobId =
|
||||||
JobId fut.id()
|
JobId fut.id()
|
||||||
|
|
||||||
proc processJobs*[T](jobs: JobQueue[T]) {.async.} =
|
proc processJobs*[T](jobs: JobQueue[T]) {.async, raises: [].} =
|
||||||
## Starts a "detached" async processor for a given job queue.
|
## Starts a "detached" async processor for a given job queue.
|
||||||
##
|
##
|
||||||
## This processor waits for events from the queue in the JobQueue
|
## This processor waits for events from the queue in the JobQueue
|
||||||
@ -52,12 +52,12 @@ proc processJobs*[T](jobs: JobQueue[T]) {.async.} =
|
|||||||
const tn: string = $(JobQueue[T])
|
const tn: string = $(JobQueue[T])
|
||||||
info "Processing jobs in job queue for type ", type = tn
|
info "Processing jobs in job queue for type ", type = tn
|
||||||
while jobs.running:
|
while jobs.running:
|
||||||
let res = await(jobs.queue.wait()).get()
|
let (id, ret) = await(jobs.queue.wait()).get()
|
||||||
trace "got job result", jobResult = $res
|
trace "got job result", jobId = id
|
||||||
let (id, ret) = res
|
releaseMemory(id) # always release any retained memory
|
||||||
releaseMemory(id) # release any retained memory
|
|
||||||
var fut: Future[T]
|
var fut: Future[T]
|
||||||
if jobs.futures.pop(id, fut):
|
if jobs.futures.pop(id, fut):
|
||||||
|
if not fut.finished():
|
||||||
fut.complete(ret)
|
fut.complete(ret)
|
||||||
else:
|
else:
|
||||||
raise newException(IndexDefect, "missing future: " & $id)
|
raise newException(IndexDefect, "missing future: " & $id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user