[go: up one dir, main page]

AgnostikExecutor

Trait AgnostikExecutor 

Source
pub trait AgnostikExecutor {
    // Required methods
    fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output> 
       where F: Future + Send + 'static,
             <F as Future>::Output: Send + 'static;
    fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T> 
       where F: FnOnce() -> T + Send + 'static,
             T: Send + 'static;
    fn block_on<F>(&self, future: F) -> <F as Future>::Output
       where F: Future + Send + 'static,
             <F as Future>::Output: Send + 'static;
}
Expand description

and wait for a future to finish.

Required Methods§

Source

fn spawn<F>(&self, future: F) -> JoinHandle<<F as Future>::Output>
where F: Future + Send + 'static, <F as Future>::Output: Send + 'static,

Spawns an asynchronous task using the underlying executor.

Source

fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T>
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,

Runs the provided closure on a thread, which can execute blocking tasks asynchronously.

Source

fn block_on<F>(&self, future: F) -> <F as Future>::Output
where F: Future + Send + 'static, <F as Future>::Output: Send + 'static,

Blocks until the future has finished.

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§