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 standard library.
std › Io › Threaded › AlertableSyscall › start Private Function start Doc Source Private Function std.Io.Threaded.AlertableSyscall.start
fn start () Io .Cancelable !AlertableSyscall File Io/Threaded.zig: 1471
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495 fn start () Io .Cancelable !AlertableSyscall {
const thread = Thread .current orelse return .{ .thread = null };
switch (thread .cancel_protection ) {
.blocked => return .{ .thread = null },
.unblocked => {},
}
const old_status = thread .status .fetchOr (.{
.cancelation = @fromBackingInt (@intCast (0b010 )),
.awaitable = .null ,
}, .monotonic );
switch (old_status .cancelation ) {
.parked => unreachable ,
.blocked => unreachable ,
.blocked_alertable => unreachable ,
.blocked_canceling => unreachable ,
.blocked_alertable_canceling => unreachable ,
.none => return .{ .thread = thread }, // new status is `.blocked_alertable`
.canceling => {
// Status is unchanged (still `.canceling`)---change to `.canceled` before return.
thread .status .store (.{ .cancelation = .canceled , .awaitable = old_status .awaitable }, .monotonic );
return error .Canceled ;
},
.canceled => return .{ .thread = null }, // new status is `.canceled` (unchanged)
}
}