mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Fix deadlock in Auto_Reset_Event
This commit is contained in:
@@ -228,15 +228,14 @@ thread.
|
|||||||
*/
|
*/
|
||||||
auto_reset_event_signal :: proc "contextless" (e: ^Auto_Reset_Event) {
|
auto_reset_event_signal :: proc "contextless" (e: ^Auto_Reset_Event) {
|
||||||
old_status := atomic_load_explicit(&e.status, .Relaxed)
|
old_status := atomic_load_explicit(&e.status, .Relaxed)
|
||||||
|
new_status := old_status + 1 if old_status < 1 else 1
|
||||||
for {
|
for {
|
||||||
new_status := old_status + 1 if old_status < 1 else 1
|
|
||||||
if _, ok := atomic_compare_exchange_weak_explicit(&e.status, old_status, new_status, .Release, .Relaxed); ok {
|
if _, ok := atomic_compare_exchange_weak_explicit(&e.status, old_status, new_status, .Release, .Relaxed); ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if old_status < 0 {
|
if old_status < 0 {
|
||||||
sema_post(&e.sema)
|
sema_post(&e.sema)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user