Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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. Public Function

swapCancelProtection

Public Function
std.Io.swapCancelProtection
pub fn swapCancelProtection(io: Io, new: CancelProtection) CancelProtection

Updates the current task's cancel protection state (see CancelProtection).

The typical usage for this function is to protect a block of code from cancelation:

const old_cancel_protect = io.swapCancelProtection(.blocked);
defer _ = io.swapCancelProtection(old_cancel_protect);
doSomeWork() catch |err| switch (err) {
    error.Canceled => unreachable,
};

For a description of cancelation and cancelation points, see Future.cancel.

Params

File

Io.zig:1465
1465
1466
1467
pub fn swapCancelProtection(io: Io, new: CancelProtection) CancelProtection {
    return io.vtable.swapCancelProtection(io.userdata, new);
}