use std::future::IntoFuture;
use std::sync::OnceLock;
fn runtime() -> &'static tokio::runtime::Runtime {
static RUNTIME: OnceLock<tokio::runtime::Runtime> = OnceLock::new();
RUNTIME.get_or_init(|| {
tokio::runtime::Builder::new_multi_thread()
.worker_threads(2)
.thread_name("exedev")
.enable_all()
.build()
.expect("exedev: cannot start a Tokio runtime")
})
}
pub trait BlockOn: IntoFuture {
fn block_on(self) -> Self::Output;
}
impl<F: IntoFuture> BlockOn for F {
fn block_on(self) -> Self::Output {
runtime().block_on(self.into_future())
}
}