pub struct TaskHandle<T> { /* private fields */ }Available on crate feature
async only.Expand description
Opaque handle returned by Context::spawn.
Store the handle and pass it to Context::poll on
subsequent frames to retrieve the task’s result. Dropping the handle
cancels the in-flight task (via tokio::task::JoinHandle::abort), so
keep it alive for as long as you care about the result.
The type parameter T ties the handle to the future’s output type so
poll can downcast safely. Two handles never collide: each carries a
unique id, so even two TaskHandle<String> live simultaneously route
their results to the correct caller.
Requires the async feature.
Trait Implementations§
Source§impl<T> Debug for TaskHandle<T>
impl<T> Debug for TaskHandle<T>
Source§impl<T> Drop for TaskHandle<T>
impl<T> Drop 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> UnsafeUnpin 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