Skip to main content

TokioBlockingTaskHandle

Struct TokioBlockingTaskHandle 

Source
pub struct TokioBlockingTaskHandle<R, E> { /* private fields */ }
Expand description

Tracked handle for tasks submitted to Tokio’s blocking task pool.

This handle wraps the standard TrackedTask result/status endpoint and additionally keeps Tokio’s AbortHandle so pre-start cancellation can remove queued spawn_blocking work from the Tokio runtime.

Tokio cannot abort blocking work after the closure has started. In that case Self::cancel reports CancelResult::AlreadyRunning through the underlying tracked task state.

Implementations§

Source§

impl<R, E> TokioBlockingTaskHandle<R, E>

Source

pub fn get(self) -> Result<R, TaskExecutionError<E>>
where R: Send, E: Send,

Waits for the task to finish and returns its final result.

This method blocks the current thread until a result is available.

§Returns

The final task result.

Source

pub fn try_get(self) -> TryGet<TokioBlockingTaskHandle<R, E>, R, E>
where R: Send, E: Send,

Attempts to retrieve the final result without blocking.

§Returns

A ready result or the pending handle.

Source

pub fn is_done(&self) -> bool
where R: Send, E: Send,

Returns whether the task has installed a terminal state.

§Returns

true after the task succeeds, fails, panics, is cancelled, or loses its runner endpoint.

Source

pub fn status(&self) -> TaskStatus

Returns the currently observed task status.

§Returns

The current task status.

Source

pub fn cancel(&self) -> CancelResult

Attempts to cancel this task before its blocking closure starts.

When cancellation wins the pending-state race, this method also aborts the Tokio spawn_blocking task so queued work is dropped without waiting for an available blocking thread.

§Returns

The observed cancellation outcome.

Trait Implementations§

Source§

impl<R, E> IntoFuture for TokioBlockingTaskHandle<R, E>

Source§

fn into_future( self, ) -> <TokioBlockingTaskHandle<R, E> as IntoFuture>::IntoFuture

Converts this tracked handle into a future resolving to the task result.

Source§

type Output = Result<R, TaskExecutionError<E>>

The output that the future will produce on completion.
Source§

type IntoFuture = TaskHandleFuture<R, E>

Which kind of future are we turning this into?
Source§

impl<R, E> TaskResultHandle<R, E> for TokioBlockingTaskHandle<R, E>
where R: Send, E: Send,

Source§

fn is_done(&self) -> bool

Returns whether the tracked state is terminal.

Source§

fn get(self) -> Result<R, TaskExecutionError<E>>

Blocks until the underlying result handle yields a result.

Source§

fn try_get(self) -> TryGet<TokioBlockingTaskHandle<R, E>, R, E>

Attempts to retrieve the underlying result without blocking.

Source§

impl<R, E> TrackedTaskHandle<R, E> for TokioBlockingTaskHandle<R, E>
where R: Send, E: Send,

Source§

fn status(&self) -> TaskStatus

Returns the currently observed task status.

Source§

fn cancel(&self) -> CancelResult

Attempts to cancel the task before it starts.

Auto Trait Implementations§

§

impl<R, E> Freeze for TokioBlockingTaskHandle<R, E>

§

impl<R, E> !RefUnwindSafe for TokioBlockingTaskHandle<R, E>

§

impl<R, E> Send for TokioBlockingTaskHandle<R, E>
where R: Send, E: Send,

§

impl<R, E> !Sync for TokioBlockingTaskHandle<R, E>

§

impl<R, E> Unpin for TokioBlockingTaskHandle<R, E>

§

impl<R, E> UnsafeUnpin for TokioBlockingTaskHandle<R, E>

§

impl<R, E> !UnwindSafe for TokioBlockingTaskHandle<R, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoResult<T> for T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.