diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-08-24 16:16:53 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-08-27 00:44:35 +0100 |
| commit | 6808ce27bdca14d3876ac607c94f75ea054db7b8 (patch) | |
| tree | c30b229113d60243a1257fad597ec919c99e3dad /lib/std/Thread | |
| parent | a3a737e9a68fae96519743a644209b4a30cf3b58 (diff) | |
| download | zig-6808ce27bdca14d3876ac607c94f75ea054db7b8.tar.gz zig-6808ce27bdca14d3876ac607c94f75ea054db7b8.zip | |
compiler,lib,test,langref: migrate `@setCold` to `@branchHint`
Diffstat (limited to 'lib/std/Thread')
| -rw-r--r-- | lib/std/Thread/Futex.zig | 8 | ||||
| -rw-r--r-- | lib/std/Thread/Mutex.zig | 2 | ||||
| -rw-r--r-- | lib/std/Thread/ResetEvent.zig | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index c067368041..fe22fa2011 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -27,7 +27,7 @@ const atomic = std.atomic; /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically /// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`. pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void { - @setCold(true); + @branchHint(.cold); Impl.wait(ptr, expect, null) catch |err| switch (err) { error.Timeout => unreachable, // null timeout meant to wait forever @@ -43,7 +43,7 @@ pub fn wait(ptr: *const atomic.Value(u32), expect: u32) void { /// The checking of `ptr` and `expect`, along with blocking the caller, is done atomically /// and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same `ptr`. pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS for no-op timeouts. if (timeout_ns == 0) { @@ -56,7 +56,7 @@ pub fn timedWait(ptr: *const atomic.Value(u32), expect: u32, timeout_ns: u64) er /// Unblocks at most `max_waiters` callers blocked in a `wait()` call on `ptr`. pub fn wake(ptr: *const atomic.Value(u32), max_waiters: u32) void { - @setCold(true); + @branchHint(.cold); // Avoid calling into the OS if there's nothing to wake up. if (max_waiters == 0) { @@ -1048,7 +1048,7 @@ pub const Deadline = struct { /// - A spurious wake occurs. /// - The deadline expires; In which case `error.Timeout` is returned. pub fn wait(self: *Deadline, ptr: *const atomic.Value(u32), expect: u32) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Check if we actually have a timeout to wait until. // If not just wait "forever". diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig index 032c19b7dd..be421c4c94 100644 --- a/lib/std/Thread/Mutex.zig +++ b/lib/std/Thread/Mutex.zig @@ -169,7 +169,7 @@ const FutexImpl = struct { } fn lockSlow(self: *@This()) void { - @setCold(true); + @branchHint(.cold); // Avoid doing an atomic swap below if we already know the state is contended. // An atomic swap unconditionally stores which marks the cache-line as modified unnecessarily. diff --git a/lib/std/Thread/ResetEvent.zig b/lib/std/Thread/ResetEvent.zig index b7e5758780..cbc5a2a31c 100644 --- a/lib/std/Thread/ResetEvent.zig +++ b/lib/std/Thread/ResetEvent.zig @@ -107,7 +107,7 @@ const FutexImpl = struct { } fn waitUntilSet(self: *Impl, timeout: ?u64) error{Timeout}!void { - @setCold(true); + @branchHint(.cold); // Try to set the state from `unset` to `waiting` to indicate // to the set() thread that others are blocked on the ResetEvent. |
