Trait executors::futures_executor::FuturesExecutor[][src]

pub trait FuturesExecutor: Executor + Sync + 'static {
    fn spawn<R: Send + 'static>(
        &self,
        future: impl Future<Output = R> + 'static + Send
    ) -> JoinHandle<R>; }

A trait for spawning futures on an Executor

Required methods

fn spawn<R: Send + 'static>(
    &self,
    future: impl Future<Output = R> + 'static + Send
) -> JoinHandle<R>
[src]

Spawn future on the pool and return a handle to the result

Handles can be awaited like any other future.

Examples

Execute an “expensive” computation on the pool and block the main thread waiting for the result to become available.

use executors::*;
use futures::executor::block_on;
// initialise some executor
let handle = executor.spawn(async move { 2*2 });
let result = block_on(handle);
assert_eq!(4, result);
Loading content...

Implementors

impl FuturesExecutor for executors::crossbeam_channel_pool::ThreadPool[src]

impl<P> FuturesExecutor for executors::crossbeam_workstealing_pool::ThreadPool<P> where
    P: Parker + Clone + 'static, 
[src]

Loading content...