mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-16 00:00:12 +02:00
20 lines
410 B
Rust
20 lines
410 B
Rust
use tokio_threadpool;
|
|
|
|
use self::tokio_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()
|
|
}
|