mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 13:00:28 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user