pub struct JoinHandle<T> { /* private fields */ }Expand description
A native local task handle. It is neither Send nor Sync.
Returned by crate::rt::spawn() and crate::rt::Runtime::spawn(). Dropping
the handle detaches the task unless cancel_on_drop
is enabled.
Awaiting it yields the task’s output, or an error if no output is available,
for example after cancellation, a task panic, or runtime shutdown.
Implementations§
Source§impl<T> JoinHandle<T>
impl<T> JoinHandle<T>
Sourcepub fn cancel_on_drop(self) -> Self
pub fn cancel_on_drop(self) -> Self
Sourcepub fn cancel(self)
pub fn cancel(self)
Requests cancellation and discards the result without waiting for cleanup.
The future is dropped when the runtime next processes the task, or during runtime shutdown. A running poll is not interrupted.
Sourcepub fn detach(self)
👎Deprecated since 4.5.0: Drop the handle instead if cancel_on_drop() is not enabled
pub fn detach(self)
Drop the handle instead if cancel_on_drop() is not enabled
Detaches the task so it continues running independently.
Overrides cancel_on_drop without requesting cancellation.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the task completed or was closed without an output.