mirror of
https://github.com/logos-storage/apatheia.git
synced 2026-01-06 23:13:10 +00:00
fix decrement and free in channel
This commit is contained in:
parent
6fba03afa5
commit
a2b74aeb33
@ -1,4 +1,3 @@
|
||||
import std/channels
|
||||
|
||||
import ./types
|
||||
|
||||
@ -9,15 +8,21 @@ import chronos/threadsync
|
||||
export types
|
||||
|
||||
type
|
||||
ChanPtr[T] = ptr Channel[T]
|
||||
|
||||
proc allocSharedChannel[T](): ChanPtr[T] =
|
||||
cast[ChanPtr[T]](allocShared0(sizeof(Channel[T])))
|
||||
|
||||
type
|
||||
AsyncQueue*[T] = object
|
||||
signal: ThreadSignalPtr
|
||||
chan*: T
|
||||
chan*: ChanPtr[T]
|
||||
|
||||
proc new*[T](tp: typedesc[AsyncQueue[T]]): AsyncQueue[T] {.raises: [ApatheiaSignalErr].} =
|
||||
let res = ThreadSignalPtr.new()
|
||||
if res.isErr():
|
||||
raise newException(ApatheiaSignalErr, msg: res.err())
|
||||
else:
|
||||
result.signal = res.get()
|
||||
result.signal = res.get()
|
||||
result.chan = allocSharedChannel()
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user