From b2c2235e587bb8902dbf35ef84373bb5f616a814 Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Mon, 9 Sep 2024 19:11:44 -0400 Subject: [PATCH] Fix `recursive_benaphore_try_lock` Previously, if the owner called this, it would fail. --- core/sync/extended.odin | 8 ++++---- 1 file 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