aboutsummaryrefslogtreecommitdiff
path: root/core/sync
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-09 19:11:44 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-10 14:52:20 -0400
commitb2c2235e587bb8902dbf35ef84373bb5f616a814 (patch)
tree01aa2270b96111b0fb9b2691e777be8b95a649b1 /core/sync
parent3a6010918033e1548e84d57a07074cdbf802ff9b (diff)
Fix `recursive_benaphore_try_lock`
Previously, if the owner called this, it would fail.
Diffstat (limited to 'core/sync')
-rw-r--r--core/sync/extended.odin8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/sync/extended.odin b/core/sync/extended.odin
index 83cc648b4..d5521935a 100644
--- a/core/sync/extended.odin
+++ b/core/sync/extended.odin
@@ -474,10 +474,10 @@ recursive_benaphore_try_lock :: proc "contextless" (b: ^Recursive_Benaphore) ->
tid := current_thread_id()
if b.owner == tid {
atomic_add_explicit(&b.counter, 1, .Acquire)
- }
-
- if v, _ := atomic_compare_exchange_strong_explicit(&b.counter, 0, 1, .Acquire, .Acquire); v != 0 {
- return false
+ } else {
+ if v, _ := atomic_compare_exchange_strong_explicit(&b.counter, 0, 1, .Acquire, .Acquire); v != 0 {
+ return false
+ }
}
// inside the lock
b.owner = tid