Struct tokio::task::AbortHandle
source · pub struct AbortHandle { /* private fields */ }
rt
and tokio_unstable
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.
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.
Implementations§
source§impl AbortHandle
impl AbortHandle
sourcepub fn abort(&self)
pub fn abort(&self)
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.
sourcepub fn id(&self) -> Id
pub fn id(&self) -> Id
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.