Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include omission from previous PR #76

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading