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