pub struct TaskHandle<T> { /* private fields */ }
Expand description
A handle to a spawned task
A TaskHandle
can be awaited to wait for the completion of its associated task and get its
result.
A TaskHandle
detaches its task when dropped. This means the it can no longer be awaited, but
the executor will still poll its task.
This is created by Executor::spawn
and Executor::spawn_rc
.
Implementations§
Source§impl<T> TaskHandle<T>
impl<T> TaskHandle<T>
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Cancel the task
Deletes the task from the executor so that it won’t be polled again.
If the handle is awaited after cancellation, it might still complete if the task was already finished before it was cancelled. However, the likelier outcomes is that it never completes.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Check if this task is finished
If this returns true
, the next poll
call is guaranteed to return Poll::Ready
.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check if this task has been cancelled
Trait Implementations§
Source§impl<T> Future for TaskHandle<T>
impl<T> Future for TaskHandle<T>
Auto Trait Implementations§
impl<T> Freeze for TaskHandle<T>
impl<T> !RefUnwindSafe for TaskHandle<T>
impl<T> !Send for TaskHandle<T>
impl<T> !Sync for TaskHandle<T>
impl<T> Unpin for TaskHandle<T>
impl<T> !UnwindSafe for TaskHandle<T>
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
Mutably borrows from an owned value. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more