fire signal

This commit is contained in:
Jaremy Creechley 2024-02-09 21:19:45 -07:00
parent 94c9ad01f6
commit b6b77a686c
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300

View File

@ -29,9 +29,12 @@ proc new*[T](tp: typedesc[AsyncQueue[T]]): AsyncQueue[T] {.raises: [ApatheiaSign
proc send*[T](c: AsyncQueue[T], msg: sink T) {.inline.} =
## Sends a message to a thread. `msg` is copied.
c.chan.send(msg)
c.signal.fireSync()
proc trySend*[T](c: AsyncQueue[T], msg: sink T): bool {.inline.} =
c.chan.trySend(msg)
result = c.chan.trySend(msg)
if result:
c.signal.fireSync()
proc recv*[T](c: AsyncQueue[T]): T =
c.chan.recv()