Skip to main content

Spawner

Trait Spawner 

Source
pub trait Spawner:
    Send
    + Sync
    + 'static {
    // Required method
    fn spawn(&self, fut: BoxFuture);
}
Expand description

An executor hook that drives the futures produced by async exports.

Implemented for any Fn(BoxFuture) + Send + Sync + 'static, so a closure that forwards to a runtime handle is enough.

Required Methods§

Source

fn spawn(&self, fut: BoxFuture)

Schedule fut to run to completion. Must not block the caller: the launcher that invokes it is on the consumer’s thread.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> Spawner for F
where F: Fn(BoxFuture) + Send + Sync + 'static,