pub trait Executor: Send + Sync {
// Required methods
fn block_on(
&self,
future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
);
fn spawn(
&self,
future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
fn spawn_blocking(
&self,
task: Box<dyn FnOnce() + Send>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
fn spawn_local(
&self,
future: Pin<Box<dyn Future<Output = ()> + 'static>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>;
}
Expand description
Trait abstracting over an executor.
Required Methods§
Sourcefn block_on(&self, future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>)
fn block_on(&self, future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>)
Blocks until the future has finished.
Sourcefn spawn(
&self,
future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
fn spawn( &self, future: Pin<Box<dyn Future<Output = ()> + Send + 'static>>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'static>>
Spawns an asynchronous task using the underlying executor.