Skip to content

Commit

Permalink
Move around mutex guard
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Sep 8, 2024
1 parent 300b01d commit e72d0ba
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions core/sync/chan/chan.odin
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit e72d0ba

Please sign in to comment.