starfish-sdk 1.0.0

海星SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::future::Future;
use tokio::runtime::{Builder, Handle, Runtime};

static mut INS: Option<Runtime> = None;

pub fn init() {
	let rt: Runtime = Builder::new_multi_thread().enable_all().build().unwrap();
	unsafe { INS = Some(rt) }
}

pub fn get() -> &'static Runtime {
	unsafe { INS.as_ref().unwrap() }
}

pub fn blocking<F: Future>(future: F) -> F::Output {
	tokio::task::block_in_place(move || Handle::current().block_on(future))
}