pub struct CancelToken { /* private fields */ }Expand description
The producer’s handle on a consumer’s cancel token, the final parameter
of a cancellable async fn. When the consumer cancels, the runtime drops
the function’s future and completes the call with the cancelled code;
poll is_cancelled only for cooperative
cleanup (work on other threads, say).
The producer’s handle on a consumer’s cancel token, accepted as the final
parameter of a cancellable async fn.
The handle holds its own reference to the token, so it stays valid after
the consumer destroys its reference. Cancellation is enforced by the
runtime (the producer’s future is dropped as soon as the token fires); a
producer polls is_cancelled only when it wants to
clean up cooperatively, for example between batches of work on another
thread.
Implementations§
Source§impl CancelToken
impl CancelToken
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Whether the consumer has requested cancellation.