Trait executors::futures_executor::FuturesExecutor [−][src]
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]
&self,
future: impl Future<Output = R> + 'static + Send
) -> JoinHandle<R>
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);
Implementors
impl FuturesExecutor for executors::crossbeam_channel_pool::ThreadPool
[src]
fn spawn<R: Send + 'static>(
&self,
future: impl Future<Output = R> + 'static + Send
) -> JoinHandle<R>
[src]
&self,
future: impl Future<Output = R> + 'static + Send
) -> JoinHandle<R>
impl<P> FuturesExecutor for executors::crossbeam_workstealing_pool::ThreadPool<P> where
P: Parker + Clone + 'static,
[src]
P: Parker + Clone + 'static,