pub struct TokioExecution<R, E> { /* private fields */ }Expand description
Future-backed execution returned by TokioExecutor.
This struct implements Future:
Output is Result<R, E> — the
success value R or the callable’s error E. Await this type (on a
Tokio-driven async context) to receive that result; until then the underlying
blocking task may still be running.
Tokio join errors are not part of that Result: task panics are resumed and
cancellations panic when the future is awaited.
§Type Parameters
R- The task success value.E- The task error value.
Implementations§
Source§impl<R, E> TokioExecution<R, E>
impl<R, E> TokioExecution<R, E>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the Tokio task has finished.
§Returns
true if the underlying Tokio task has completed.
Sourcepub fn cancel(&self) -> bool
pub fn cancel(&self) -> bool
Requests cancellation of the underlying Tokio task.
Tokio can cancel a blocking task only before it starts. If the blocking closure is already running, this request is best-effort and awaiting the execution will still wait for the closure to finish.
§Returns
true after the cancellation request has been sent to Tokio.
Trait Implementations§
Source§impl<R, E> Future for TokioExecution<R, E>
impl<R, E> Future for TokioExecution<R, E>
Source§fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>
Polls the underlying Tokio task.
§Parameters
cx- Async task context used to register the current waker.
§Returns
Poll::Ready with the callable result when the Tokio task completes,
or Poll::Pending while the task is still running.
§Panics
Panics if Tokio reports the blocking task was cancelled. If the task panicked, this method resumes the original panic payload.