pub struct JoinHandle<T> { /* private fields */ }Expand description
Handle to a spawned task. Await to get the result.
Dropping the handle detaches the task — it continues running but the
output is dropped when the task completes. Use abort()
to cancel the task.
JoinHandle is !Send and !Sync — it must stay on the executor thread.
Implementations§
Source§impl<T> JoinHandle<T>
impl<T> JoinHandle<T>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the task has completed (output is ready).
Sourcepub fn abort(self) -> bool
pub fn abort(self) -> bool
Abort the task and consume the handle.
The future is dropped on the next poll cycle. Consumes the handle so it cannot be awaited after abort — this is enforced at the type level rather than via a runtime panic.
Returns true if the task was still running, false if it had
already completed (output is dropped by JoinHandle::drop).
Trait Implementations§
Source§impl<T> Drop for JoinHandle<T>
impl<T> Drop for JoinHandle<T>
Source§impl<T: 'static> Future for JoinHandle<T>
impl<T: 'static> Future for JoinHandle<T>
Auto Trait Implementations§
impl<T> Freeze for JoinHandle<T>
impl<T> RefUnwindSafe for JoinHandle<T>where
T: RefUnwindSafe,
impl<T> !Send for JoinHandle<T>
impl<T> !Sync for JoinHandle<T>
impl<T> Unpin for JoinHandle<T>where
T: Unpin,
impl<T> UnsafeUnpin for JoinHandle<T>
impl<T> UnwindSafe for JoinHandle<T>where
T: UnwindSafe,
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