[][src]Trait futures_util::compat::Executor01CompatExt

pub trait Executor01CompatExt: Executor01<Executor01Future> + Clone + Send + 'static {
    fn compat(self) -> Executor01As03<Self>
    where
        Self: Sized
; }

Extension trait for futures 0.1 Executor.

Required Methods

Converts a futures 0.1 Executor into a futures 0.3 Spawn.

This example is not tested
#![feature(async_await, await_macro, futures_api)]
use futures::Future;
use futures::future::{FutureExt, TryFutureExt};
use futures::compat::Executor01CompatExt;
use futures::spawn;
use tokio_threadpool::ThreadPool;

let pool01 = ThreadPool::new();
let spawner03 = pool01.sender().clone().compat();

let future03 = async {
    println!("Running on the pool");
    spawn!(async {
        println!("Spawned!");
    }).unwrap();
};

let future01 = future03.unit_error().boxed().compat(spawner03);

pool01.spawn(future01);
pool01.shutdown_on_idle().wait().unwrap();

Implementors