Skip to main content

v_common/runtime_wrapper/
runtime_tokio.rs

1pub struct RuntimeWrapper {
2    pub runtime: ::tokio::runtime::Runtime,
3}
4
5impl RuntimeWrapper {
6    pub fn new() -> Self {
7        let runtime = ::tokio::runtime::Runtime::new().unwrap();
8        RuntimeWrapper {
9            runtime,
10        }
11    }
12
13    pub fn version(&self) -> &'static str {
14        "tokio 1.0"
15    }
16
17    pub fn block_on<F>(&mut self, future: F) -> F::Output
18    where
19        F: std::future::Future,
20    {
21        self.runtime.block_on(future)
22    }
23}