| author | |
| committer | |
| log | 1182f06c1487149282f699d6265e7ef91e8a56ad |
| tree | fb33d5155d8a2c73704afd1bd4662da8e4644ddd |
| parent | 9787df9421ad9d3fcb08cc7b394656542b16cfae |
Timeout.none implicitly seems to mean indefinitely nearly
everywhere I can see. However, Io.Threaded.sleep() has a
short-circuit at the top which treats Timeout.none as effectively
zero (no sleep at all), even though the per-target functions it
calls afterwards would otherwise would honor .none correctly.
This patch removes this (presumably erronenous) short-circuit and
documents Timeout.none's meaning explicitly.2 files changed, 1 insertions(+), 1 deletions(-)
lib/std/Io.zig+1| ... | ... | @@ -1139,6 +1139,7 @@ pub const Duration = struct { |
| 1139 | 1139 | |
| 1140 | 1140 | /// Declares under what conditions an operation should return `error.Timeout`. |
| 1141 | 1141 | pub const Timeout = union(enum) { |
| 1142 | /// `.none` will wait forever | |
| 1142 | 1143 | none, |
| 1143 | 1144 | duration: Clock.Duration, |
| 1144 | 1145 | deadline: Clock.Timestamp, |
lib/std/Io/Threaded.zig-1| ... | ... | @@ -11711,7 +11711,6 @@ fn nowWasi(clock: Io.Clock) Io.Timestamp { |
| 11711 | 11711 | |
| 11712 | 11712 | fn sleep(userdata: ?*anyopaque, timeout: Io.Timeout) Io.Cancelable!void { |
| 11713 | 11713 | const t: *Threaded = @ptrCast(@alignCast(userdata)); |
| 11714 | if (timeout == .none) return; | |
| 11715 | 11714 | if (use_parking_sleep) return parking_sleep.sleep(timeout); |
| 11716 | 11715 | if (native_os == .wasi) return sleepWasi(t, timeout); |
| 11717 | 11716 | if (@TypeOf(posix.system.clock_nanosleep) != void) return sleepPosix(timeout); |