pub struct AbortHandle { /* private fields */ }
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§
§impl AbortHandle
impl AbortHandle
pub 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.
See also the module level docs for more information on cancellation.
pub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
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.