diff options
| author | Veikka Tuominen <git@vexu.eu> | 2024-03-11 22:42:32 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-11 22:42:32 +0200 |
| commit | 4f782d1e853accbe1c4bfab2617c3813d4b1e59f (patch) | |
| tree | 0eb768171ecfb058fba72d199afc951af206f8fb /lib/std/Thread/Condition.zig | |
| parent | d0c06ca7127110a8afeb0ef524a197049892db21 (diff) | |
| parent | 6067d39522f939c08dd3f3ea4fb5889ff0024e72 (diff) | |
| download | zig-4f782d1e853accbe1c4bfab2617c3813d4b1e59f.tar.gz zig-4f782d1e853accbe1c4bfab2617c3813d4b1e59f.zip | |
Merge pull request #18994 from ExpidusOS/feat/container-layout-rename-fields
std.builtin: make enum fields lowercase
Diffstat (limited to 'lib/std/Thread/Condition.zig')
| -rw-r--r-- | lib/std/Thread/Condition.zig | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index b1154f8bd0..39b8483950 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -163,7 +163,7 @@ const WindowsImpl = struct { if (comptime builtin.mode == .Debug) { // The internal state of the DebugMutex needs to be handled here as well. - mutex.impl.locking_thread.store(0, .Unordered); + mutex.impl.locking_thread.store(0, .unordered); } const rc = os.windows.kernel32.SleepConditionVariableSRW( &self.condition, @@ -173,7 +173,7 @@ const WindowsImpl = struct { ); if (comptime builtin.mode == .Debug) { // The internal state of the DebugMutex needs to be handled here as well. - mutex.impl.locking_thread.store(std.Thread.getCurrentId(), .Unordered); + mutex.impl.locking_thread.store(std.Thread.getCurrentId(), .unordered); } // Return error.Timeout if we know the timeout elapsed correctly. @@ -212,8 +212,8 @@ const FutexImpl = struct { // - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed the state update + the epoch change) // // Acquire barrier to ensure the epoch load happens before the state load. - var epoch = self.epoch.load(.Acquire); - var state = self.state.fetchAdd(one_waiter, .Monotonic); + var epoch = self.epoch.load(.acquire); + var state = self.state.fetchAdd(one_waiter, .monotonic); assert(state & waiter_mask != waiter_mask); state += one_waiter; @@ -231,30 +231,30 @@ const FutexImpl = struct { // Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return. while (state & signal_mask != 0) { const new_state = state - one_waiter - one_signal; - state = self.state.cmpxchgWeak(state, new_state, .Acquire, .Monotonic) orelse return; + state = self.state.cmpxchgWeak(state, new_state, .acquire, .monotonic) orelse return; } // Remove the waiter we added and officially return timed out. const new_state = state - one_waiter; - state = self.state.cmpxchgWeak(state, new_state, .Monotonic, .Monotonic) orelse return err; + state = self.state.cmpxchgWeak(state, new_state, .monotonic, .monotonic) orelse return err; } }, }; - epoch = self.epoch.load(.Acquire); - state = self.state.load(.Monotonic); + epoch = self.epoch.load(.acquire); + state = self.state.load(.monotonic); // Try to wake up by consuming a signal and decremented the waiter we added previously. // Acquire barrier ensures code before the wake() which added the signal happens before we decrement it and return. while (state & signal_mask != 0) { const new_state = state - one_waiter - one_signal; - state = self.state.cmpxchgWeak(state, new_state, .Acquire, .Monotonic) orelse return; + state = self.state.cmpxchgWeak(state, new_state, .acquire, .monotonic) orelse return; } } } fn wake(self: *Impl, comptime notify: Notify) void { - var state = self.state.load(.Monotonic); + var state = self.state.load(.monotonic); while (true) { const waiters = (state & waiter_mask) / one_waiter; const signals = (state & signal_mask) / one_signal; @@ -275,7 +275,7 @@ const FutexImpl = struct { // Reserve the amount of waiters to wake by incrementing the signals count. // Release barrier ensures code before the wake() happens before the signal it posted and consumed by the wait() threads. const new_state = state + (one_signal * to_wake); - state = self.state.cmpxchgWeak(state, new_state, .Release, .Monotonic) orelse { + state = self.state.cmpxchgWeak(state, new_state, .release, .monotonic) orelse { // Wake up the waiting threads we reserved above by changing the epoch value. // NOTE: a waiting thread could miss a wake up if *exactly* ((1<<32)-1) wake()s happen between it observing the epoch and sleeping on it. // This is very unlikely due to how many precise amount of Futex.wake() calls that would be between the waiting thread's potential preemption. @@ -288,7 +288,7 @@ const FutexImpl = struct { // - T1: s = LOAD(&state) // - T2: UPDATE(&state, signal) + FUTEX_WAKE(&epoch) // - T1: s & signals == 0 -> FUTEX_WAIT(&epoch, e) (missed both epoch change and state change) - _ = self.epoch.fetchAdd(1, .Release); + _ = self.epoch.fetchAdd(1, .release); Futex.wake(&self.epoch, to_wake); return; }; |
