This commit is contained in:
Jaremy Creechley 2024-02-09 18:55:29 -07:00
parent 0c10e88aa8
commit 98ddd00d62
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 8 additions and 3 deletions

View File

@ -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()

View File

@ -1,3 +1,4 @@
type
ApatheiaException* = ref object of CatchableError
ApatheiaSignalErr* = ref object of ApatheiaException