Cancellation Token¶
Import: import system.core;
CancellationToken¶
Read-only view of a CancellationSource for cooperative checks at await boundaries. @shared (closed-graph over @shared CancellationSource) so tokens can cross into workers.
current¶
Returns the cancellation token inherited from the current structured task.
resolve¶
Explicit tokens override the current structured task; None inherits its token.
is_cancelled¶
True when the owning source has been cancelled.
wait_cancelled¶
Suspends until cancellation and returns true. Completion or releasing a cancelled future detaches its subscription.
wait¶
Awaits a future or cancellation using scheduler notifications. Cancellation cancels the supplied future; already performed side effects are preserved.
wait_void¶
Awaits a void future or cancellation, returning true when the operation completes.
throw_if_cancelled¶
Panics with CancelledError when already cancelled.
check¶
Ok(Unit()) when still running; Err(CancelledError) when cancelled.
is_cancelled_opt¶
True when token is Some and already cancelled.
throw_if_opt¶
Panics when token is Some and already cancelled.
rejected¶
Returns err when the explicit or inherited token is cancelled; otherwise Ok(Unit()).