From 8a14a656fbd8843628b61e5a20877b40b772482c Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:05:29 -0400 Subject: [PATCH] Fix `chan.can_send` for unbuffered channels `w_waiting` is the signal that says a caller is waiting to be able to send something. It is incremented upon send and - in the case of an unbuffered channel - it can only hold one message. Therefore, check that `w_waiting` is zero instead. --- core/sync/chan/chan.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sync/chan/chan.odin b/core/sync/chan/chan.odin index f0b04f3b4..5b9a764b4 100644 --- a/core/sync/chan/chan.odin +++ b/core/sync/chan/chan.odin @@ -444,7 +444,7 @@ can_send :: proc "contextless" (c: ^Raw_Chan) -> bool { if is_buffered(c) { return c.queue.len < c.queue.cap } - return sync.atomic_load(&c.r_waiting) > 0 + return sync.atomic_load(&c.w_waiting) == 0 }