[][src]Module tokio_global::single

Single threaded runtime module

Runtime is stored in thread local variable

Example

use tokio_global::single as rt;

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 fut = futures::future::ok::<u32, u32>(5);
let result = rt::block_on(fut).expect("Ok");
assert_eq!(result, 5);

Structs

Runtime

Guard that controls lifetime of Runtime module

Functions

block_on

Run a future to completion on the Tokio runtime.

handle

Retrieves tokio's handle.

init

Initializes new runtime and returns guard that controls its lifetime.

run

Starts function within tokio runtime that returns future and awaits its completion.

spawn

Spawns future on runtime's event loop.