pub trait Executor: Send + Sync {
// Required methods
fn spawn(&self, fut: BoxFuture<'static, ()>) -> AbortHandleRef;
fn spawn_cpu(
&self,
task: Box<dyn FnOnce() + Send + 'static>,
) -> AbortHandleRef;
fn spawn_blocking_io(
&self,
task: Box<dyn FnOnce() + Send + 'static>,
) -> AbortHandleRef;
}Expand description
Trait used to abstract over different async runtimes.
Required Methods§
Sourcefn spawn(&self, fut: BoxFuture<'static, ()>) -> AbortHandleRef
fn spawn(&self, fut: BoxFuture<'static, ()>) -> AbortHandleRef
Spawns a future to be executed on the runtime.
The future should continue to be polled in the background by the runtime.
The returned AbortHandle may be used to optimistically cancel the future.
Sourcefn spawn_cpu(&self, task: Box<dyn FnOnce() + Send + 'static>) -> AbortHandleRef
fn spawn_cpu(&self, task: Box<dyn FnOnce() + Send + 'static>) -> AbortHandleRef
Spawns a CPU-bound task for execution on the runtime.
The returned AbortHandle may be used to optimistically cancel the task if it has not
yet started executing.
Sourcefn spawn_blocking_io(
&self,
task: Box<dyn FnOnce() + Send + 'static>,
) -> AbortHandleRef
fn spawn_blocking_io( &self, task: Box<dyn FnOnce() + Send + 'static>, ) -> AbortHandleRef
Spawns a blocking I/O task for execution on the runtime.
The returned AbortHandle may be used to optimistically cancel the task if it has not
yet started executing.