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
2024-09-09 16:05:29 -04:00
parent e9a6a34480
commit 8a14a656fb

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
}