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>
impl<R, E> TokioBlockingTaskHandle<R, E>
Sourcepub fn get(self) -> Result<R, TaskExecutionError<E>>
pub fn get(self) -> Result<R, TaskExecutionError<E>>
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.
Sourcepub fn try_get(self) -> TryGet<TokioBlockingTaskHandle<R, E>, R, E>
pub fn try_get(self) -> TryGet<TokioBlockingTaskHandle<R, E>, R, E>
Attempts to retrieve the final result without blocking.
§Returns
A ready result or the pending handle.
Sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
Returns whether the task has installed a terminal state.
§Returns
true after the task succeeds, fails, panics, is cancelled, or loses
its runner endpoint.
Sourcepub fn status(&self) -> TaskStatus
pub fn status(&self) -> TaskStatus
Sourcepub fn cancel(&self) -> CancelResult
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>
impl<R, E> IntoFuture for TokioBlockingTaskHandle<R, E>
Source§fn into_future(
self,
) -> <TokioBlockingTaskHandle<R, E> as IntoFuture>::IntoFuture
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>>
type Output = Result<R, TaskExecutionError<E>>
Source§type IntoFuture = TaskHandleFuture<R, E>
type IntoFuture = TaskHandleFuture<R, E>
Source§impl<R, E> TaskResultHandle<R, E> for TokioBlockingTaskHandle<R, E>
impl<R, E> TaskResultHandle<R, E> for TokioBlockingTaskHandle<R, E>
Source§fn get(self) -> Result<R, TaskExecutionError<E>>
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>
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>
impl<R, E> TrackedTaskHandle<R, E> for TokioBlockingTaskHandle<R, E>
Source§fn status(&self) -> TaskStatus
fn status(&self) -> TaskStatus
Returns the currently observed task status.
Source§fn cancel(&self) -> CancelResult
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>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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