diff options
| author | kprotty <kbutcher6200@gmail.com> | 2021-06-26 13:00:54 -0500 |
|---|---|---|
| committer | kprotty <kbutcher6200@gmail.com> | 2021-06-30 21:49:00 -0500 |
| commit | 7b323f84ca876c86bbe06f132d5a5d3775def3a2 (patch) | |
| tree | aa136c9710efbc131c138d658a9bb000475de5b9 /lib/std/Thread | |
| parent | c6fb968a3d702fbf8067164052ccf562f5e362ef (diff) | |
| download | zig-7b323f84ca876c86bbe06f132d5a5d3775def3a2.tar.gz zig-7b323f84ca876c86bbe06f132d5a5d3775def3a2.zip | |
std.Thread: more fixes
Diffstat (limited to 'lib/std/Thread')
| -rw-r--r-- | lib/std/Thread/Futex.zig | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/std/Thread/Futex.zig b/lib/std/Thread/Futex.zig index b1b2128caa..de7dd5e73b 100644 --- a/lib/std/Thread/Futex.zig +++ b/lib/std/Thread/Futex.zig @@ -64,10 +64,9 @@ pub fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut} /// Unblocks at most `num_waiters` callers blocked in a `wait()` call on `ptr`. /// `num_waiters` of 1 unblocks at most one `wait(ptr, ...)` and `maxInt(u32)` unblocks effectively all `wait(ptr, ...)`. pub fn wake(ptr: *const Atomic(u32), num_waiters: u32) void { - if (num_waiters == 0 or single_threaded) { - return; - } - + if (single_threaded) return; + if (num_waiters == 0) return; + return OsFutex.wake(ptr, num_waiters); } @@ -80,7 +79,23 @@ else if (target.isDarwin()) else if (std.builtin.link_libc) PosixFutex else - @compileError("Operating System unsupported"); + UnsupportedFutex; + +const UnsupportedFutex = struct { + fn wait(ptr: *const Atomic(u32), expect: u32, timeout: ?u64) error{TimedOut}!void { + return unsupported(.{ptr, expect, timeout}); + } + + fn wake(ptr: *const Atomic(u32), num_waiters: u32) void { + return unsupported(.{ptr, num_waiters}); + } + + fn unsupported(unused: anytype) noreturn { + @compileLog("Unsupported operating system", target.os.tag); + _ = unused; + unreachable; + } +}; const WindowsFutex = struct { const windows = std.os.windows; |
