mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Correct explicit atomic orderings
This commit is contained in:
@@ -298,7 +298,7 @@ atomic_cond_wait :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
atomic_cond_wait_with_timeout :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex, duration: time.Duration) -> (ok: bool) {
|
atomic_cond_wait_with_timeout :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex, duration: time.Duration) -> (ok: bool) {
|
||||||
state := u32(atomic_load(&c.state))
|
state := u32(atomic_load_explicit(&c.state, .Relaxed))
|
||||||
unlock(m)
|
unlock(m)
|
||||||
ok = futex_wait_with_timeout(&c.state, state, duration)
|
ok = futex_wait_with_timeout(&c.state, state, duration)
|
||||||
lock(m)
|
lock(m)
|
||||||
@@ -307,12 +307,12 @@ atomic_cond_wait_with_timeout :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex, duratio
|
|||||||
|
|
||||||
|
|
||||||
atomic_cond_signal :: proc(c: ^Atomic_Cond) {
|
atomic_cond_signal :: proc(c: ^Atomic_Cond) {
|
||||||
atomic_add_explicit(&c.state, 1, .Relaxed)
|
atomic_add_explicit(&c.state, 1, .Release)
|
||||||
futex_signal(&c.state)
|
futex_signal(&c.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_cond_broadcast :: proc(c: ^Atomic_Cond) {
|
atomic_cond_broadcast :: proc(c: ^Atomic_Cond) {
|
||||||
atomic_add_explicit(&c.state, 1, .Relaxed)
|
atomic_add_explicit(&c.state, 1, .Release)
|
||||||
futex_broadcast(&c.state)
|
futex_broadcast(&c.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +351,6 @@ atomic_sema_wait_with_timeout :: proc(s: ^Atomic_Sema, duration: time.Duration)
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
|
||||||
original_count := atomic_load_explicit(&s.count, .Relaxed)
|
original_count := atomic_load_explicit(&s.count, .Relaxed)
|
||||||
for start := time.tick_now(); original_count == 0; /**/ {
|
for start := time.tick_now(); original_count == 0; /**/ {
|
||||||
remaining := duration - time.tick_since(start)
|
remaining := duration - time.tick_since(start)
|
||||||
|
|||||||
Reference in New Issue
Block a user