Files
tokio/tokio-fs/tests/pool/mod.rs
T

19 lines
392 B
Rust
Raw Normal View History

use tokio_executor::threadpool::Builder;
2018-11-16 14:50:06 -08:00
2019-07-11 11:05:49 -05:00
use std::future::Future;
2018-11-16 14:50:06 -08:00
use std::io;
2019-07-11 11:05:49 -05:00
use std::sync::mpsc;
2018-11-16 14:50:06 -08:00
pub fn run<F>(f: F)
where
2019-07-11 11:05:49 -05:00
F: Future<Output = io::Result<()>> + Send + 'static,
2018-11-16 14:50:06 -08:00
{
let pool = Builder::new().pool_size(1).build();
2019-07-11 11:05:49 -05:00
let (tx, rx) = mpsc::channel();
pool.spawn(async move {
f.await.unwrap();
tx.send(()).unwrap();
});
rx.recv().unwrap()
2018-11-16 14:50:06 -08:00
}