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.
This commit is contained in:
Feoramund committed 2024-09-10 14:52:20 -04:00
1 parent e9a6a34480
commit 8a14a656fb
1 file changed
+1 -1
+1 -1
View File
@@ -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
}