mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
Fix recursive_benaphore_try_lock
Previously, if the owner called this, it would fail.
This commit is contained in:
@@ -474,10 +474,10 @@ 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
|
||||||
|
|||||||
Reference in New Issue
Block a user