Struct tokio::task::AbortHandle

source ·
pub struct AbortHandle { /* private fields */ }
Available on crate feature rt only.
Expand description

An owned permission to abort a spawned task, without awaiting its completion.

Unlike a JoinHandle, an AbortHandle does not represent the permission to await the task’s completion, only to terminate it.

The task may be aborted by calling the AbortHandle::abort method. Dropping an AbortHandle releases the permission to terminate the task — it does not abort the task.

Implementations§

Abort the task associated with the handle.

Awaiting a cancelled task might complete as usual if the task was already completed at the time it was cancelled, but most likely it will fail with a cancelled JoinError.

If the task was already cancelled, such as by JoinHandle::abort, this method will do nothing.

Checks if the task associated with this AbortHandle has finished.

Please note that this method can return false even if abort has been called on the task. This is because the cancellation process may take some time, and this method does not return true until it has completed.

Available on tokio_unstable only.

Returns a task ID that uniquely identifies this task relative to other currently spawned tasks.

Note: This is an unstable API. The public API of this type may break in 1.x releases. See the documentation on unstable features for details.

Trait Implementations§

Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more