Struct AbortHandle
struct AbortHandle { ... }
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.
Be aware that tasks spawned using spawn_blocking cannot be aborted
because they are not async. If you call abort on a spawn_blocking task,
then this will not have any effect, and the task will continue running
normally. The exception is if the task has not started running yet; in that
case, calling abort may prevent the task from starting.
Implementations
impl AbortHandle
fn abort(self: &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.Be aware that tasks spawned using
spawn_blockingcannot be aborted because they are not async. If you callaborton aspawn_blockingtask, then this will not have any effect, and the task will continue running normally. The exception is if the task has not started running yet; in that case, callingabortmay prevent the task from starting.See also the module level docs for more information on cancellation.
fn is_finished(self: &Self) -> boolChecks if the task associated with this
AbortHandlehas finished.Please note that this method can return
falseeven ifaborthas been called on the task. This is because the cancellation process may take some time, and this method does not returntrueuntil it has completed.fn id(self: &Self) -> IdReturns a task ID that uniquely identifies this task relative to other currently spawned tasks.
impl Clone for AbortHandle
fn clone(self: &Self) -> SelfReturns a cloned
AbortHandlethat can be used to remotely abort this task.
impl Debug for AbortHandle
fn fmt(self: &Self, fmt: &mut Formatter<'_>) -> Result
impl Drop for AbortHandle
fn drop(self: &mut Self)
impl Freeze for AbortHandle
impl RefUnwindSafe for AbortHandle
impl Send for AbortHandle
impl Sync for AbortHandle
impl Unpin for AbortHandle
impl UnsafeUnpin for AbortHandle
impl UnwindSafe for AbortHandle
impl<T> Any for AbortHandle
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for AbortHandle
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for AbortHandle
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for AbortHandle
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for AbortHandle
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for AbortHandle
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for AbortHandle
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for AbortHandle
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for AbortHandle
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>