Spawn

Trait 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§