Remove prev from Atomic_Cond

This commit is contained in:
gingerBill
2022-04-27 15:29:21 +01:00
parent df0df73540
commit d6cfb60506

View File

@@ -287,12 +287,10 @@ atomic_recursive_mutex_guard :: proc(m: ^Atomic_Recursive_Mutex) -> bool {
// An Atomic_Cond must not be copied after first use
Atomic_Cond :: struct {
state: Futex,
prev: u32,
}
atomic_cond_wait :: proc(c: ^Atomic_Cond, m: ^Atomic_Mutex) {
state := u32(atomic_load(&c.state))
atomic_store(&c.prev, state)
state := u32(atomic_load_explicit(&c.state, .Relaxed))
unlock(m)
futex_wait(&c.state, state)
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) {
state := 1 + atomic_load(&c.prev)
atomic_store(&c.state, Futex(state))
atomic_add_explicit(&c.state, 1, .Relaxed)
futex_signal(&c.state)
}
atomic_cond_broadcast :: proc(c: ^Atomic_Cond) {
state := 1 + atomic_load(&c.prev)
atomic_store(&c.state, Futex(state))
atomic_add_explicit(&c.state, 1, .Relaxed)
futex_broadcast(&c.state)
}