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

cancel

Public Function
std.Io.Future.cancel
pub fn cancel(f: *@This(), io: Io) Result

Equivalent to await but places a cancelation request. This causes the task to receive error.Canceled from its next "cancelation point" (if any). A cancelation point is a call to a function in Io which can return error.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 ignore error.Canceled. However, to defer handling cancelation requests, see also recancel and CancelProtection.

Idempotent. Not threadsafe.

Params

  • f: *@This()
  • io: Io

File

Io.zig:1305
1305
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;
        }