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.
pub fn swapCancelProtection(io: Io, new: CancelProtection) CancelProtection
pub fn swapCancelProtection(io: Io, new: CancelProtection) CancelProtection {
return io.vtable.swapCancelProtection(io.userdata, new);
}