summaryrefslogtreecommitdiffstats
path: root/tokio-threadpool
diff options
context:
space:
mode:
authorSerho Liu <SerhoLiu@gmail.com>2018-08-08 10:44:45 +0800
committerCarl Lerche <me@carllerche.com>2018-08-07 19:44:45 -0700
commit5304557d1d86b262b8fcc471f4c085058d474c29 (patch)
treea38b99f0c1bf00aff401678134855b304acff178 /tokio-threadpool
parentfdb2f613577b0777975950b0181700a889c88807 (diff)
Fix tokio threadpool readme examples (#521)
Diffstat (limited to 'tokio-threadpool')
-rw-r--r--tokio-threadpool/README.md16
1 files changed, 9 insertions, 7 deletions
diff --git a/tokio-threadpool/README.md b/tokio-threadpool/README.md
index 6ed817c8..3c89b265 100644
--- a/tokio-threadpool/README.md
+++ b/tokio-threadpool/README.md
@@ -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();
}
```