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) -> TaskResult<R, E>
pub fn get(self) -> TaskResult<R, 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<Self, R, E>
pub fn try_get(self) -> TryGet<Self, 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) -> Self::IntoFuture
fn into_future(self) -> Self::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§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.