Files
tokio/tokio-fs/tests/pool/mod.rs
T
Carl Lerche 3b27dc31d2 threadpool: move threadpool into tokio-executor (#1452)
The threadpool is behind a feature flag.

Refs: #1264
2019-08-15 13:09:02 -07:00

19 lines
392 B
Rust

use tokio_executor::threadpool::Builder;
use std::future::Future;
use std::io;
use std::sync::mpsc;
pub fn run<F>(f: F)
where
F: Future<Output = io::Result<()>> + Send + 'static,
{
let pool = Builder::new().pool_size(1).build();
let (tx, rx) = mpsc::channel();
pool.spawn(async move {
f.await.unwrap();
tx.send(()).unwrap();
});
rx.recv().unwrap()
}