From 3b27981daf941716e87e5eddc3f598ef1be49af6 Mon Sep 17 00:00:00 2001 From: Antonis Geralis Date: Mon, 26 Aug 2024 22:10:37 +0300 Subject: [PATCH 1/2] fix bug with recvIso --- threading/channels.nim | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/threading/channels.nim b/threading/channels.nim index db68c34..72c1cae 100644 --- a/threading/channels.nim +++ b/threading/channels.nim @@ -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. From fb2cc4342905d59de694d2a57ecb94781f3e92af Mon Sep 17 00:00:00 2001 From: Antonis Geralis Date: Mon, 26 Aug 2024 22:32:57 +0300 Subject: [PATCH 2/2] fix link --- threading/channels.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threading/channels.nim b/threading/channels.nim index 72c1cae..a2e2f5a 100644 --- a/threading/channels.nim +++ b/threading/channels.nim @@ -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))