Trait async_main::Spawn

source ·
pub trait Spawn: Clone {
    // Required method
    fn spawn_local(&self, f: impl Future<Output = ()> + 'static);

    // Provided method
    fn spawn(&self, f: impl Future<Output = ()> + Send + 'static) { ... }
}
Expand description

Implementation for spawning tasks on an executor.

Required Methods§

source

fn spawn_local(&self, f: impl Future<Output = ()> + 'static)

Spawn a [Future] without the Send requirement.

This forces the executor to always run the task on the same thread that this method is called on.

Provided Methods§

source

fn spawn(&self, f: impl Future<Output = ()> + Send + 'static)

Spawn a [Future] that is Send.

This allows the executor to run the task on whatever thread it determines is most efficient.

Implementors§