Trait near_async::futures::FutureSpawner

source ·
pub trait FutureSpawner {
    // Required method
    fn spawn_boxed(&self, description: &'static str, f: BoxFuture<'static, ()>);
}
Expand description

Abstraction for something that can drive futures.

Rust futures don’t run by itself. It needs a driver to execute it. This can for example be a thread, a thread pool, or Actix. This trait abstracts over the execution mechanism.

The reason why we need an abstraction is (1) we can intercept the future spawning to add additional instrumentation (2) we can support driving the future with TestLoop for testing.

Required Methods§

source

fn spawn_boxed(&self, description: &'static str, f: BoxFuture<'static, ()>)

Trait Implementations§

source§

impl FutureSpawnerExt for dyn FutureSpawner + '_

source§

fn spawn<F>(&self, description: &'static str, f: F)
where F: Future<Output = ()> + Send + 'static,

Implementors§