fn sleepNanosleep(t: *Threaded, timeout: Io.Timeout) Io.Cancelable!void 11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951fn sleepNanosleep(t: *Threaded, timeout: Io.Timeout) Io.Cancelable!void {
const t_io = io(t);
const sec_type = @typeInfo(posix.timespec).@"struct".field_types[0];
const nsec_type = @typeInfo(posix.timespec).@"struct".field_types[1];
var timespec: posix.timespec = t: {
const d = timeout.toDurationFromNow(t_io) orelse break :t .{
.sec = std.math.maxInt(sec_type),
.nsec = std.math.maxInt(nsec_type),
};
break :t timestampToPosix(d.raw.toNanoseconds());
};
const syscall: Syscall = try .start();
while (true) {
switch (posix.errno(posix.system.nanosleep(×pec, ×pec))) {
.INTR => {
try syscall.checkCancel();
continue;
},
// This prong handles success as well as unexpected errors.
else => return syscall.finish(),
}
}
}