diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2024-08-27 06:10:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-27 06:10:56 +0100 |
| commit | d3c6f7179c7a6086ab9cdbaed231da9a1f0b4dee (patch) | |
| tree | a75bc8abc129a679fce0673165e04fa7283f2823 /lib/std/Thread/Futex.zig | |
| parent | d9147b91a601ad2442aaa43f4dba2d01b25d803d (diff) | |
| parent | 4c0f021c2e4270c7392df7250a5d8f2431dcc54f (diff) | |
| download | zig-d3c6f7179c7a6086ab9cdbaed231da9a1f0b4dee.tar.gz zig-d3c6f7179c7a6086ab9cdbaed231da9a1f0b4dee.zip | |
Merge pull request #21214 from mlugg/branch-hint-and-export
Implement `@branchHint` and new `@export` usage
Diffstat (limited to 'lib/std/Thread/Futex.zig')
| -rw-r--r-- | lib/std/Thread/Futex.zig | 8 |
1 files changed, 4 insertions, 4 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". |
