mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-04 22:13:13 +00:00
logging
This commit is contained in:
parent
1a54fc42c1
commit
17576f94e2
@ -9,6 +9,7 @@ import chronos
|
||||
import chronicles
|
||||
|
||||
export queues
|
||||
export chronicles
|
||||
|
||||
logScope:
|
||||
# Lexical properties are typically assigned to a constant:
|
||||
@ -40,16 +41,18 @@ proc processJobs*[T](jobs: JobQueue[T]) {.async.} =
|
||||
## This processor waits for events from the queue in the JobQueue
|
||||
## and complete the associated futures.
|
||||
|
||||
const tn: string = $(JobQueue[T])
|
||||
info "Processing jobs in job queue for type ", type=tn
|
||||
while jobs.running:
|
||||
info "Processing jobs in job queue"
|
||||
let res = await(jobs.queue.wait()).get()
|
||||
debug "got job result", jobResult = res
|
||||
trace "got job result", jobResult = $res
|
||||
let (id, ret) = res
|
||||
var fut: Future[T]
|
||||
if jobs.futures.pop(id, fut):
|
||||
fut.complete(ret)
|
||||
else:
|
||||
raise newException(IndexDefect, "missing future: " & $id)
|
||||
info "Processing jobs in job queue"
|
||||
|
||||
proc createFuture*[T](jobs: JobQueue[T], name: static string): (JobResult[T], Future[T]) =
|
||||
let fut = newFuture[T](name)
|
||||
|
||||
@ -13,7 +13,7 @@ import apatheia/tasks
|
||||
|
||||
proc addNums(a, b: float): float {.asyncTask.} =
|
||||
os.sleep(100)
|
||||
echo "adding: ", a, " + ", b
|
||||
# info "adding: ", a=a, b=b
|
||||
return a + b
|
||||
|
||||
proc addNumValues(vals: openArray[float]): float {.asyncTask.} =
|
||||
@ -21,7 +21,7 @@ proc addNumValues(vals: openArray[float]): float {.asyncTask.} =
|
||||
result = 0.0
|
||||
for x in vals:
|
||||
result += x
|
||||
echo "adding sums: ", vals
|
||||
# echo "adding sums: ", vals
|
||||
|
||||
suite "async tests":
|
||||
var tp = Taskpool.new(num_threads = 2) # Default to the number of hardware threads.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user