mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-10-01 12:20:39 +00:00
Fix tokio threadpool readme examples (#521)
This commit is contained in:
parent
fdb2f61357
commit
5304557d1d
@ -25,19 +25,21 @@ It's 10x slower.
|
||||
extern crate tokio_threadpool;
|
||||
extern crate futures;
|
||||
|
||||
use tokio_threadpool::*;
|
||||
use futures::*;
|
||||
use tokio_threadpool::ThreadPool;
|
||||
use futures::{Future, lazy};
|
||||
use futures::sync::oneshot;
|
||||
|
||||
pub fn main() {
|
||||
let (tx, _pool) = ThreadPool::new();
|
||||
let pool = ThreadPool::new();
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
let res = oneshot::spawn(future::lazy(|| {
|
||||
pool.spawn(lazy(|| {
|
||||
println!("Running on the pool");
|
||||
Ok::<_, ()>("complete")
|
||||
}), &tx);
|
||||
tx.send("complete").map_err(|e| println!("send error, {}", e))
|
||||
}));
|
||||
|
||||
println!("Result: {:?}", res.wait());
|
||||
println!("Result: {:?}", rx.wait());
|
||||
pool.shutdown().wait().unwrap();
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user