AsyncHandle

Trait AsyncHandle 

Source
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§

Source

fn is_finished(&self) -> bool

Whether a task can be join immediately

Source

fn detach(self)

Detach the task to run in the background without waiting for its result.

After calling this method, the task will continue running until it completes or until its runtime dropped.

Source

fn abort(self)

Abort the task execution, don’t care for it’s result

Implementors§