mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:24:33 +01:00
std.Io.Event: fix single-threaded implementation
This commit is contained in:
parent
b191e50be5
commit
633eb247ab
2 changed files with 6 additions and 3 deletions
|
|
@ -1467,7 +1467,7 @@ pub const Event = enum(u32) {
|
|||
pub fn waitTimeout(event: *Event, io: Io, timeout: Timeout) WaitTimeoutError!void {
|
||||
if (@cmpxchgStrong(Event, event, .unset, .waiting, .acquire, .acquire)) |prev| switch (prev) {
|
||||
.unset => unreachable,
|
||||
.waiting => assert(!builtin.single_threaded), // invalid state
|
||||
.waiting => {},
|
||||
.is_set => return,
|
||||
};
|
||||
errdefer {
|
||||
|
|
|
|||
|
|
@ -2461,7 +2461,10 @@ fn cancel(
|
|||
}
|
||||
|
||||
fn futexWait(userdata: ?*anyopaque, ptr: *const u32, expected: u32, timeout: Io.Timeout) Io.Cancelable!void {
|
||||
if (builtin.single_threaded) unreachable; // Deadlock.
|
||||
if (builtin.single_threaded) {
|
||||
assert(timeout != .none); // Deadlock.
|
||||
return;
|
||||
}
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
const t_io = ioBasic(t);
|
||||
const timeout_ns: ?u64 = ns: {
|
||||
|
|
@ -2479,7 +2482,7 @@ fn futexWaitUncancelable(userdata: ?*anyopaque, ptr: *const u32, expected: u32)
|
|||
}
|
||||
|
||||
fn futexWake(userdata: ?*anyopaque, ptr: *const u32, max_waiters: u32) void {
|
||||
if (builtin.single_threaded) unreachable; // Nothing to wake up.
|
||||
if (builtin.single_threaded) return; // Nothing to wake up.
|
||||
const t: *Threaded = @ptrCast(@alignCast(userdata));
|
||||
_ = t;
|
||||
Thread.futexWake(ptr, max_waiters);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue