mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-02 21:13:08 +00:00
queues
This commit is contained in:
parent
0c10e88aa8
commit
98ddd00d62
@ -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()
|
||||
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
type
|
||||
ApatheiaException* = ref object of CatchableError
|
||||
ApatheiaSignalErr* = ref object of ApatheiaException
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user