diff --git a/src/apatheia/queues.nim b/src/apatheia/queues.nim index 04827f7..e607ec3 100644 --- a/src/apatheia/queues.nim +++ b/src/apatheia/queues.nim @@ -1,3 +1,5 @@ +import std/channels + import ./types import chronos @@ -10,11 +12,13 @@ type AsyncQueue*[T] = object signal: ThreadSignalPtr - item*: T + chan*: T -proc new*[T](tp: typedesc[AsyncQueue[T]]): AsyncQueue[T] {.raises: [ApatheiaException].} = +proc new*[T](tp: typedesc[AsyncQueue[T]]): AsyncQueue[T] {.raises: [ApatheiaSignalErr].} = let res = ThreadSignalPtr.new() if res.isErr(): - raise newException(ApatheiaException, msg: res.err()) + raise newException(ApatheiaSignalErr, msg: res.err()) + else: + result.signal = res.get() diff --git a/src/apatheia/types.nim b/src/apatheia/types.nim index 44f93ab..a2a845b 100644 --- a/src/apatheia/types.nim +++ b/src/apatheia/types.nim @@ -1,3 +1,4 @@ type ApatheiaException* = ref object of CatchableError + ApatheiaSignalErr* = ref object of ApatheiaException