Executor

Trait Executor 

Source
pub trait Executor {
    // Required methods
    fn block_on<T, F: Future<Output = T>>(&self, f: F) -> T
       where Self: Sized;
    fn spawn<T: Send + 'static, F: Future<Output = T> + Send + 'static>(
        &self,
        f: F,
    ) -> impl Task<T> + 'static
       where Self: Sized;
    fn spawn_blocking<T: Send + 'static, F: FnOnce() -> T + Send + 'static>(
        &self,
        f: F,
    ) -> impl Task<T> + 'static
       where Self: Sized;
}
Expand description

A common interface for spawning futures on top of an executor

Required Methods§

Source

fn block_on<T, F: Future<Output = T>>(&self, f: F) -> T
where Self: Sized,

Block on a future until completion

Source

fn spawn<T: Send + 'static, F: Future<Output = T> + Send + 'static>( &self, f: F, ) -> impl Task<T> + 'static
where Self: Sized,

Spawn a future and return a handle to track its completion.

Source

fn spawn_blocking<T: Send + 'static, F: FnOnce() -> T + Send + 'static>( &self, f: F, ) -> impl Task<T> + 'static
where Self: Sized,

Convert a blocking task into a future, spawning it on a decicated thread pool

Implementors§