mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Remove prev from Atomic_Cond
This commit is contained in:
@@ -287,12 +287,10 @@ atomic_recursive_mutex_guard :: proc(m: ^Atomic_Recursive_Mutex) -> bool {
|
|||||||
// An Atomic_Cond must not be copied after first use
|
// An Atomic_Cond must not be copied after first use
|
||||||
Atomic_Cond :: struct {
|
Atomic_Cond :: struct {
|
||||||
state: Futex,
|
state: Futex,
|
||||||
prev: u32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_cond_wait :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex) {
|
atomic_cond_wait :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex) {
|
||||||
state := u32(atomic_load(&c.state))
|
state := u32(atomic_load_explicit(&c.state, .Relaxed))
|
||||||
atomic_store(&c.prev, state)
|
|
||||||
unlock(m)
|
unlock(m)
|
||||||
futex_wait(&c.state, state)
|
futex_wait(&c.state, state)
|
||||||
lock(m)
|
lock(m)
|
||||||
@@ -309,14 +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) {
|
||||||
state := 1 + atomic_load(&c.prev)
|
atomic_add_explicit(&c.state, 1, .Relaxed)
|
||||||
atomic_store(&c.state, Futex(state))
|
|
||||||
futex_signal(&c.state)
|
futex_signal(&c.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_cond_broadcast :: proc(c: ^Atomic_Cond) {
|
atomic_cond_broadcast :: proc(c: ^Atomic_Cond) {
|
||||||
state := 1 + atomic_load(&c.prev)
|
atomic_add_explicit(&c.state, 1, .Relaxed)
|
||||||
atomic_store(&c.state, Futex(state))
|
|
||||||
futex_broadcast(&c.state)
|
futex_broadcast(&c.state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user