This commit is contained in:
Andreas Rumpf 2020-01-27 22:50:10 +01:00 • committed by GitHub
commit c8418651b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -367,7 +367,8 @@ proc sendImpl(q: PRawChannel, typ: PNimType, msg: pointer, noBlock: bool): bool
proc send*[TMsg](c: var Channel[TMsg], msg: sink TMsg) {.inline.} =
## Sends a message to a thread. `msg` is deeply copied.
discard sendImpl(cast[PRawChannel](addr c), cast[PNimType](getTypeInfo(msg)), unsafeAddr(msg), false)
wasMoved(msg)
when defined(gcDestructors):
wasMoved(msg)
proc trySend*[TMsg](c: var Channel[TMsg], msg: sink TMsg): bool {.inline.} =
## Tries to send a message to a thread.
@ -377,8 +378,9 @@ proc trySend*[TMsg](c: var Channel[TMsg], msg: sink TMsg): bool {.inline.} =
## Returns `false` if the message was not sent because number of pending items
## in the channel exceeded `maxItems`.
result = sendImpl(cast[PRawChannel](addr c), cast[PNimType](getTypeInfo(msg)), unsafeAddr(msg), true)
if result:
wasMoved(msg)
when defined(gcDestructors):
if result:
wasMoved(msg)
proc llRecv(q: PRawChannel, res: pointer, typ: PNimType) =
q.ready = true