Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Threaded.zig › sleepNanosleep
sleepNanosleep
Threaded.sleepNanosleep
fn sleepNanosleep (t : *Threaded , timeout : Io .Timeout ) Io .Cancelable !void
File
Code
fn 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 ;
},
else => return syscall .finish (),
}
}
}