mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-07 15:33:09 +00:00
queues
This commit is contained in:
parent
0c10e88aa8
commit
98ddd00d62
@ -1,3 +1,5 @@
|
|||||||
|
import std/channels
|
||||||
|
|
||||||
import ./types
|
import ./types
|
||||||
|
|
||||||
import chronos
|
import chronos
|
||||||
@ -10,11 +12,13 @@ type
|
|||||||
|
|
||||||
AsyncQueue*[T] = object
|
AsyncQueue*[T] = object
|
||||||
signal: ThreadSignalPtr
|
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()
|
let res = ThreadSignalPtr.new()
|
||||||
if res.isErr():
|
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
|
type
|
||||||
ApatheiaException* = ref object of CatchableError
|
ApatheiaException* = ref object of CatchableError
|
||||||
|
ApatheiaSignalErr* = ref object of ApatheiaException
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user