pub trait AsyncHandle<T>: Future<Output = Result<T, ()>> + Send {
// Required methods
fn is_finished(&self) -> bool;
fn detach(self);
fn abort(self);
}Expand description
A handle for managing spawned async tasks.
This trait provides methods for waiting for a task’s completion or detaching it to run in the background.
§NOTE:
The behavior of dropping a AsyncHandle should be detach, we adopt this behavior because user is more familiar with tokio’s behavior. We don’t want bugs when dropping the task handle unnoticed.
§Type Parameters
T- The return type of the task
§Returns
A future that resolves to Ok(T) if the task completed successfully,
or Err(()) if the task panics.
Required Methods§
Sourcefn is_finished(&self) -> bool
fn is_finished(&self) -> bool
Whether a task can be join immediately