tokio-global 0.2.0

Global tokio runtime
Documentation

tokio-global

Build Crates.io Documentation

Simple way to create global tokio runtime, available from any place in code

Usage

[dependencies.tokio-global]
version = "0.2"
features = ["single"] #or multi for multithreaded runtim

Start runtime and use AutoRuntime trait to run your futures:

use tokio_global::single as rt;
use tokio_global::AutoRuntime;

let _guard = rt::init();
//Now we can exeute futures using runtime
//When guard goes out of scope though,
//we no longer can use it.

let result = futures::future::ok::<u32, u32>(5).finish().expect("Ok");
assert_eq!(result, 5);