diff options
| author | gingerBill <bill@gingerbill.org> | 2022-04-27 15:29:21 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-04-27 15:29:21 +0100 |
| commit | d6cfb6050613872c3ae70cbbe446276cec4ded12 (patch) | |
| tree | 04425d790be8a056f33c70e7c151436427ede8c9 /core/sync | |
| parent | df0df7354061c9c4f5dc295d7dae4774bc92290a (diff) | |
Remove `prev` from `Atomic_Cond`
Diffstat (limited to 'core/sync')
| -rw-r--r-- | core/sync/primitives_atomic.odin | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/core/sync/primitives_atomic.odin b/core/sync/primitives_atomic.odin index 812e5ae97..665b515ba 100644 --- a/core/sync/primitives_atomic.odin +++ b/core/sync/primitives_atomic.odin @@ -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) } |