authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-08 01:32:04+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-08 01:32:04+02:00
log2597da02544c05f7de6c209d9d4d509b74e63f73
tree0260113ab2fdf97375fad4c92df145b485d096e6
parenteff54d672b863c46c3df7f7bbc7239dd585e83f8
parent47825d7de3b9b26ab1dd7bca669b693bca2995e8

Merge pull request 'std.Io: minor Timeout-related things' (#35299) from blblack/zig:io-minor-stuff into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35299

2 files changed, 2 insertions(+), 1 deletions(-)

lib/std/Io.zig+2
...@@ -467,6 +467,7 @@ pub const OperateTimeoutError = Cancelable || Timeout.Error || ConcurrentError;...@@ -467,6 +467,7 @@ pub const OperateTimeoutError = Cancelable || Timeout.Error || ConcurrentError;
467467
468/// Performs one `Operation` with provided `timeout`.468/// Performs one `Operation` with provided `timeout`.
469pub fn operateTimeout(io: Io, operation: Operation, timeout: Timeout) OperateTimeoutError!Operation.Result {469pub fn operateTimeout(io: Io, operation: Operation, timeout: Timeout) OperateTimeoutError!Operation.Result {
470 if (timeout == .none) return io.vtable.operate(io.userdata, operation);
470 var storage: [1]Operation.Storage = undefined;471 var storage: [1]Operation.Storage = undefined;
471 var batch: Batch = .init(&storage);472 var batch: Batch = .init(&storage);
472 batch.addAt(0, operation);473 batch.addAt(0, operation);
...@@ -1147,6 +1148,7 @@ pub const Duration = struct {...@@ -1147,6 +1148,7 @@ pub const Duration = struct {
11471148
1148/// Declares under what conditions an operation should return `error.Timeout`.1149/// Declares under what conditions an operation should return `error.Timeout`.
1149pub const Timeout = union(enum) {1150pub const Timeout = union(enum) {
1151 /// `.none` will wait forever
1150 none,1152 none,
1151 duration: Clock.Duration,1153 duration: Clock.Duration,
1152 deadline: Clock.Timestamp,1154 deadline: Clock.Timestamp,
lib/std/Io/Threaded.zig-1
...@@ -11771,7 +11771,6 @@ fn nowWasi(clock: Io.Clock) Io.Timestamp {...@@ -11771,7 +11771,6 @@ fn nowWasi(clock: Io.Clock) Io.Timestamp {
1177111771
11772fn sleep(userdata: ?*anyopaque, timeout: Io.Timeout) Io.Cancelable!void {11772fn sleep(userdata: ?*anyopaque, timeout: Io.Timeout) Io.Cancelable!void {
11773 const t: *Threaded = @ptrCast(@alignCast(userdata));11773 const t: *Threaded = @ptrCast(@alignCast(userdata));
11774 if (timeout == .none) return;
11775 if (use_parking_sleep) return parking_sleep.sleep(timeout);11774 if (use_parking_sleep) return parking_sleep.sleep(timeout);
11776 if (native_os == .wasi) return sleepWasi(t, timeout);11775 if (native_os == .wasi) return sleepWasi(t, timeout);
11777 if (@TypeOf(posix.system.clock_nanosleep) != void) return sleepPosix(timeout);11776 if (@TypeOf(posix.system.clock_nanosleep) != void) return sleepPosix(timeout);