Skip to main content

Executor

Trait Executor 

pub trait Executor {
    // Required method
    fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>);
}
Expand description

Implemented on objects that can run a Future in the background.

Note: While it may be tempting to implement this trait on types such as [futures::stream::FuturesUnordered], please note that passing an Executor is optional, and that FuturesUnordered (or a similar struct) will automatically be used as fallback by libp2p. The Executor trait should therefore only be about running Futures on a separate task.

Required Methods§

fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)

Run the given future in the background until it ends.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

§

impl Executor for ThreadPool

§

fn exec(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)

Implementors§

§

impl<F> Executor for F
where F: Fn(Pin<Box<dyn Future<Output = ()> + Send>>),