Skip to content

Commit

Permalink
Merge pull request #76 from planetis-m/chan
Browse files Browse the repository at this point in the history
Include omission from previous PR
  • Loading branch information
Araq authored Aug 26, 2024
2 parents 5501a4a + fb2cc43 commit aa7ae52
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions threading/channels.nim
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ template trySend*[T](c: Chan[T], src: T): bool =
## Helper template for `trySend <#trySend,Chan[T],sinkIsolated[T]>`_.
##
## .. warning:: For repeated sends of the same value, consider using the
## `tryTake <#tryTake,Chan[T],varIsolated[T]>`_ proc with a pre-isolated
## `tryTake <#tryTake,Chan[T],Isolated[T]>`_ proc with a pre-isolated
## value to avoid unnecessary copying.
mixin isolate
trySend(c, isolate(src))
Expand Down Expand Up @@ -374,14 +374,12 @@ proc recv*[T](c: Chan[T], dst: var T) {.inline.} =
proc recv*[T](c: Chan[T]): T {.inline.} =
## Receives a message from the channel.
## A version of `recv`_ that returns the message.
discard channelReceive(c.d, result.addr, sizeof(result), true)
discard channelReceive(c.d, result.addr, sizeof(T), true)

proc recvIso*[T](c: Chan[T]): Isolated[T] {.inline.} =
## Receives a message from the channel.
## A version of `recv`_ that returns the message and isolates it.
var dst: T
discard channelReceive(c.d, dst.addr, sizeof(T), true)
result = isolate(dst)
discard channelReceive(c.d, result.addr, sizeof(T), true)

proc peek*[T](c: Chan[T]): int {.inline.} =
## Returns an estimation of the current number of messages held by the channel.
Expand Down

0 comments on commit aa7ae52

Please sign in to comment.