starfish_sdk/
runtime.rs

1use std::future::Future;
2use tokio::runtime::{Builder, Handle, Runtime};
3
4static mut INS: Option<Runtime> = None;
5
6pub fn init() {
7	let rt: Runtime = Builder::new_multi_thread().enable_all().build().unwrap();
8	unsafe { INS = Some(rt) }
9}
10
11pub fn get() -> &'static Runtime {
12	unsafe { INS.as_ref().unwrap() }
13}
14
15pub fn blocking<F: Future>(future: F) -> F::Output {
16	tokio::task::block_in_place(move || Handle::current().block_on(future))
17}