From 7f019c135dc91eb56e13c47000a047c8b9363f5a Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Fri, 16 Feb 2024 15:02:20 -0700 Subject: [PATCH] cleanup --- src/apatheia/jobs.nim | 7 +++---- src/apatheia/memretainers.nim | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/apatheia/jobs.nim b/src/apatheia/jobs.nim index dbbbe31..38fbf2e 100644 --- a/src/apatheia/jobs.nim +++ b/src/apatheia/jobs.nim @@ -43,11 +43,11 @@ template toOpenArray*[T](arr: OpenArrayHolder[T]): auto = func jobId*[T](fut: Future[T]): JobId = JobId fut.id() -proc processJobs*[T](jobs: JobQueue[T]) {.async, raises: [].} = +proc processJobs*[T](jobs: JobQueue[T]) {.async.} = ## Starts a "detached" async processor for a given job queue. ## ## This processor waits for events from the queue in the JobQueue - ## and complete the associated futures. + ## and completes the associated future. const tn: string = $(JobQueue[T]) info "Processing jobs in job queue for type ", type = tn @@ -55,8 +55,7 @@ proc processJobs*[T](jobs: JobQueue[T]) {.async, raises: [].} = let (id, ret) = await(jobs.queue.wait()).get() trace "got job result", jobId = id releaseMemory(id) # always release any retained memory - var fut: Future[T] - if jobs.futures.pop(id, fut): + if (var fut: Future[T]; jobs.futures.pop(id, fut)): if not fut.finished(): fut.complete(ret) else: diff --git a/src/apatheia/memretainers.nim b/src/apatheia/memretainers.nim index 573069a..f379b89 100644 --- a/src/apatheia/memretainers.nim +++ b/src/apatheia/memretainers.nim @@ -12,7 +12,6 @@ type StrRetainer*[T] = ref object of Retainer data*: string - var memoryRetainerTable = newTable[uint, seq[Retainer]]() proc retainMemory*(id: JobId, mem: Retainer) {.gcsafe, raises: [].} =