From 0c10e88aa81fa8bb4bb7bbc268dc69664dc0adc9 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Fri, 9 Feb 2024 18:34:56 -0700 Subject: [PATCH] queues --- src/apatheia/queues.nim | 9 +++++++++ src/apatheia/types.nim | 3 +++ 2 files changed, 12 insertions(+) create mode 100644 src/apatheia/types.nim diff --git a/src/apatheia/queues.nim b/src/apatheia/queues.nim index f8e5ded..04827f7 100644 --- a/src/apatheia/queues.nim +++ b/src/apatheia/queues.nim @@ -1,11 +1,20 @@ +import ./types import chronos +import results import chronos/threadsync +export types + type AsyncQueue*[T] = object signal: ThreadSignalPtr item*: T +proc new*[T](tp: typedesc[AsyncQueue[T]]): AsyncQueue[T] {.raises: [ApatheiaException].} = + let res = ThreadSignalPtr.new() + if res.isErr(): + raise newException(ApatheiaException, msg: res.err()) + diff --git a/src/apatheia/types.nim b/src/apatheia/types.nim new file mode 100644 index 0000000..44f93ab --- /dev/null +++ b/src/apatheia/types.nim @@ -0,0 +1,3 @@ + +type + ApatheiaException* = ref object of CatchableError