mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +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) {
|
if is_buffered(c) {
|
||||||
return c.queue.len < c.queue.cap
|
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