diff options
| author | gingerBill <bill@gingerbill.org> | 2024-09-08 14:11:05 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-09-08 14:11:05 +0100 |
| commit | e72d0ba8042f3b2ebd7d94aa7b4dae676827e952 (patch) | |
| tree | 7cad04b986f9a0d7d818fcf2c49d24d20b6a8649 | |
| parent | 300b01d77d2c676673f52ad6f6490f491d01afc9 (diff) | |
Move around mutex guard
| -rw-r--r-- | core/sync/chan/chan.odin | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/core/sync/chan/chan.odin b/core/sync/chan/chan.odin index 0c98124de..a3e0bc21f 100644 --- a/core/sync/chan/chan.odin +++ b/core/sync/chan/chan.odin @@ -421,21 +421,20 @@ raw_queue_pop :: proc "contextless" (q: ^Raw_Queue) -> (data: rawptr) { @(require_results) can_recv :: proc "contextless" (c: ^Raw_Chan) -> bool { + sync.guard(&c.mutex) if is_buffered(c) { return len(c) > 0 } - sync.guard(&c.mutex) return sync.atomic_load(&c.w_waiting) > 0 } @(require_results) can_send :: proc "contextless" (c: ^Raw_Chan) -> bool { + sync.guard(&c.mutex) if is_buffered(c) { - sync.guard(&c.mutex) return len(c) < cap(c) } - sync.guard(&c.mutex) return sync.atomic_load(&c.r_waiting) > 0 } |