summaryrefslogtreecommitdiffstats
path: root/third_party/rust/tokio-threadpool/examples/hello.rs
blob: 87eb688c2dbd99be80bceee64adc6d245c970c20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
extern crate env_logger;
extern crate futures;
extern crate tokio_threadpool;

use futures::sync::oneshot;
use futures::*;
use tokio_threadpool::*;

pub fn main() {
    let _ = ::env_logger::init();

    let pool = ThreadPool::new();
    let tx = pool.sender().clone();

    let res = oneshot::spawn(
        future::lazy(|| {
            println!("Running on the pool");
            Ok::<_, ()>("complete")
        }),
        &tx,
    );

    println!("Result: {:?}", res.wait());
}