Skip to main content

Module runtime

Module runtime 

Source
Available on crate feature tokio only.
Expand description

The tokio runtime the bundled transports poll their I/O in.

bind and bind_stream enter a runtime handle on every poll, so a caller on another executor (Bevy task pools, smol, futures::executor) owns and polls the future or stream itself: no spawned task, no channel. The handle is the current runtime’s, else a process-wide fallback runtime started on first use (one worker thread, I/O and timers enabled).

let handle = rig_http::runtime::handle()?;
assert_eq!(handle.block_on(async { 6 * 7 }), 42);

Functions§

bind
future, polled with handle entered.
bind_stream
stream, polled with handle entered.
handle
The current runtime when called inside one, else the fallback runtime, which runs for the rest of the process. A host with no tokio runtime of its own hands this to tokio-based libraries instead of starting another. A supplied current runtime must have I/O and timers enabled and stay driven until its operations finish.