Executor

Trait Executor 

Source
pub trait Executor {
    type Task<T: Send + 'static>: TaskImpl<Output = T> + Send + 'static;

    // Required methods
    fn block_on<T, F: Future<Output = T>>(&self, f: F) -> T
       where Self: Sized;
    fn spawn<T: Send + 'static, F: Future<Output = T> + Send + 'static>(
        &self,
        f: F,
    ) -> Task<Self::Task<T>> 
       where Self: Sized;
    fn spawn_blocking<T: Send + 'static, F: FnOnce() -> T + Send + 'static>(
        &self,
        f: F,
    ) -> Task<Self::Task<T>> 
       where Self: Sized;
}
Expand description

A common interface for spawning futures on top of an executor

Required Associated Types§

Source

type Task<T: Send + 'static>: TaskImpl<Output = T> + Send + 'static

The type representing the tasks the are returned when spawning a Future on the executor

Required Methods§

Source

fn block_on<T, F: Future<Output = T>>(&self, f: F) -> T
where Self: Sized,

Block on a future until completion

Source

fn spawn<T: Send + 'static, F: Future<Output = T> + Send + 'static>( &self, f: F, ) -> Task<Self::Task<T>>
where Self: Sized,

Spawn a future and return a handle to track its completion.

Source

fn spawn_blocking<T: Send + 'static, F: FnOnce() -> T + Send + 'static>( &self, f: F, ) -> Task<Self::Task<T>>
where Self: Sized,

Convert a blocking task into a future, spawning it on a decicated thread pool

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Executor for AsyncGlobalExecutor

Source§

type Task<T: Send + 'static> = AGETask<T>

Source§

impl Executor for Noop

Source§

type Task<T: Send + 'static> = NTask<T>

Source§

impl Executor for Smol

Source§

type Task<T: Send + 'static> = STask<T>

Source§

impl Executor for Tokio

Source§

type Task<T: Send + 'static> = TTask<T>

Source§

impl<E: Deref> Executor for E
where E::Target: Executor + Sized,

Source§

type Task<T: Send + 'static> = <<E as Deref>::Target as Executor>::Task<T>

Source§

impl<E: Executor, R: Reactor> Executor for RuntimeParts<E, R>

Source§

type Task<T: Send + 'static> = <E as Executor>::Task<T>

Source§

impl<RK: RuntimeKit> Executor for Runtime<RK>

Source§

type Task<T: Send + 'static> = <RK as Executor>::Task<T>