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 › sleepWasi
sleepWasi
Threaded.sleepWasi
fn sleepWasi (t : *Threaded , timeout : Io .Timeout ) Io .Cancelable !void
File
Code
fn sleepWasi (t : *Threaded , timeout : Io .Timeout ) Io .Cancelable !void {
const t_io = io (t );
const w = std .os .wasi ;
const clock : w .subscription_clock_t = if (timeout .toDurationFromNow (t_io )) |d | .{
.id = clockToWasi (d .clock ),
.timeout = std .math .lossyCast (u64 , d .raw .nanoseconds ),
.precision = 0 ,
.flags = 0 ,
} else .{
.id = .MONOTONIC ,
.timeout = std .math .maxInt (u64 ),
.precision = 0 ,
.flags = 0 ,
};
const in : w .subscription_t = .{
.userdata = 0 ,
.u = .{
.tag = .CLOCK ,
.u = .{ .clock = clock },
},
};
var event : w .event_t = undefined ;
var nevents : usize = undefined ;
const syscall : Syscall = try .start ();
_ = w .poll_oneoff (&in , &event , 1 , &nevents );
syscall .finish ();
}