aboutsummaryrefslogtreecommitdiff
path: root/core/sync
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-10 14:51:00 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-09-11 08:39:23 -0400
commita1435a6a904b2eb2b154a463c5d60f6c1f55abbc (patch)
tree8007e4fdcb4330dab343b6fe740b3b3fa208935a /core/sync
parentfec1ccd7a3f0946a84b9914875845cc9f902ee74 (diff)
Fix deadlock in `Auto_Reset_Event`
Diffstat (limited to 'core/sync')
-rw-r--r--core/sync/extended.odin9
1 files changed, 4 insertions, 5 deletions
diff --git a/core/sync/extended.odin b/core/sync/extended.odin
index 924ba92a6..0971516a3 100644
--- a/core/sync/extended.odin
+++ b/core/sync/extended.odin
@@ -228,15 +228,14 @@ thread.
*/
auto_reset_event_signal :: proc "contextless" (e: ^Auto_Reset_Event) {
old_status := atomic_load_explicit(&e.status, .Relaxed)
+ new_status := old_status + 1 if old_status < 1 else 1
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 {
break
}
-
- if old_status < 0 {
- sema_post(&e.sema)
- }
+ }
+ if old_status < 0 {
+ sema_post(&e.sema)
}
}