Skip to main content

ThreadHandle

Trait ThreadHandle 

Source
pub trait ThreadHandle<T>: Future<Output = Result<T, ()>> {
    // Required method
    fn is_finished(&self) -> bool;
}
Expand description

A handle for spawn_blocking()

This trait provides methods for waiting for a blocking task’s completion or detaching it to run in the background.

Calling await on the ThreadHandle will get Result<T, ()>.

§NOTE:

The behavior of dropping a ThreadHandle will not abort the task (since it run as pthread)

§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

Implementors§