Kaynağa Gözat

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.
Feoramund 1 yıl önce
ebeveyn
işleme
8a14a656fb
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      core/sync/chan/chan.odin

+ 1 - 1
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
 }