work around windows

This commit is contained in:
Jaremy Creechley 2024-05-20 21:10:29 +03:00
parent 56f8ff6bf3
commit 26809823ed
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
1 changed files with 5 additions and 3 deletions

View File

@ -32,13 +32,15 @@ proc newSignalQueue*[T](
maxItems: int = 0 maxItems: int = 0
): Result[SignalQueuePtr[T], ref CatchableError] = ): Result[SignalQueuePtr[T], ref CatchableError] =
## Create a signal queue compatible with Chronos async. ## Create a signal queue compatible with Chronos async.
result = success cast[ptr SignalQueue[T]](allocShared0(sizeof(SignalQueue[T]))) let queue = cast[ptr SignalQueue[T]](allocShared0(sizeof(SignalQueue[T])))
let sigRes = ThreadSignalPtr.new() let sigRes = ThreadSignalPtr.new()
if sigRes.isErr(): if sigRes.isErr():
let msg: string = sigRes.error() let msg: string = sigRes.error()
return failure((ref CatchableError)(msg: msg)) return failure((ref CatchableError)(msg: msg))
result[].signal = sigRes.get() else:
result[].chan.open(maxItems) queue[].signal = sigRes.get()
queue[].chan.open(maxItems)
return success(queue)
proc send*[T](queue: SignalQueuePtr[T], msg: T): ?!void {.raises: [].} = proc send*[T](queue: SignalQueuePtr[T], msg: T): ?!void {.raises: [].} =
## Sends a message from a regular thread. `msg` is deep copied. May block ## Sends a message from a regular thread. `msg` is deep copied. May block