Fix recursive_benaphore_try_lock

Previously, if the owner called this, it would fail.
This commit is contained in:
Feoramund
2024-09-10 14:52:20 -04:00
parent 3a60109180
commit b2c2235e58
+2 -2
View File
@@ -474,11 +474,11 @@ recursive_benaphore_try_lock :: proc "contextless" (b: ^Recursive_Benaphore) ->
tid := current_thread_id() tid := current_thread_id()
if b.owner == tid { if b.owner == tid {
atomic_add_explicit(&b.counter, 1, .Acquire) atomic_add_explicit(&b.counter, 1, .Acquire)
} } else {
if v, _ := atomic_compare_exchange_strong_explicit(&b.counter, 0, 1, .Acquire, .Acquire); v != 0 { if v, _ := atomic_compare_exchange_strong_explicit(&b.counter, 0, 1, .Acquire, .Acquire); v != 0 {
return false return false
} }
}
// inside the lock // inside the lock
b.owner = tid b.owner = tid
b.recursion += 1 b.recursion += 1