pub struct Handle<T>(/* private fields */);coroutine only.Expand description
Join handle for async task
This is a wrapper around tokio’s JoinHandle type.
Implementations§
Source§impl<T> Handle<T>
impl<T> Handle<T>
Sourcepub fn into_robust(self) -> RobustHandle<T>
pub fn into_robust(self) -> RobustHandle<T>
Convert this handle into a RobustHandle.
with a more robust mechanism for aborting.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Test if the task has finished and is ready to be joined
Sourcepub fn abort(&self)
pub fn abort(&self)
Abort the task, trying to join or co_join an aborted
task (if it’s not already completed) will return an error indicating
it’s already aborted.
If the task was completed before joining, however, it may not
see this abort call. If you always want join to indicate
aborted, see RobustHandle
Sourcepub fn abort_handle(&self) -> AbortHandle
pub fn abort_handle(&self) -> AbortHandle
Return a handle to remotely abort the task
Sourcepub fn join(self) -> Result<T>
pub fn join(self) -> Result<T>
Block the current thread to join the task
Panics are caught by the runtime, and will be returned as an Err.
Will error if the task was aborted or panicked.
If you want to handle the abort, use join_maybe_aborted
§Blocking
Do not use this in an async context, since it will block the runtime,
and will panic if the thread is currently driving IO.
Use co_join().await instead.
Sourcepub async fn co_join(self) -> Result<T>
pub async fn co_join(self) -> Result<T>
Wait for the task asynchronously
Panics are caught by the runtime, and will be returned as an Err.
Will error if the task was aborted or panicked.
If you want to handle the abort, use co_join_maybe_aborted
Sourcepub fn join_maybe_aborted(self) -> Result<Option<T>>
pub fn join_maybe_aborted(self) -> Result<Option<T>>
Like join, but returns None if the task was aborted.
Panics are caught by the runtime, and will be returned as an Err.
§Blocking
Do not use this in an async context, since it will block the runtime,
and will panic if the thread is currently driving IO.
Use co_join_maybe_aborted().await instead.
Sourcepub async fn co_join_maybe_aborted(self) -> Result<Option<T>>
pub async fn co_join_maybe_aborted(self) -> Result<Option<T>>
Like co_join, but returns None if the task was aborted.