mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
Fix tokio threadpool readme examples (#521)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user