pub fn cancel(f: *@This(), io: Io) Result f: *@This()io: Io1305
1306
1307
1308
1309
1310 pub fn cancel(f: *@This(), io: Io) Result {
const any_future = f.any_future orelse return f.result;
io.vtable.cancel(io.userdata, any_future, @ptrCast(&f.result), .of(Result));
f.any_future = null;
return f.result;
}
Equivalent to
awaitbut places a cancelation request. This causes the task to receiveerror.Canceledfrom its next "cancelation point" (if any). A cancelation point is a call to a function inIowhich can returnerror.Canceled.After cancelation of a task is requested, only the next cancelation point in that task will return
error.Canceled: future points will not re-signal the cancelation. As such, it is usually a bug to ignoreerror.Canceled. However, to defer handling cancelation requests, see alsorecancelandCancelProtection.Idempotent. Not threadsafe.