Skip to main content

select_runtime

Macro select_runtime 

Source
macro_rules! select_runtime {
    (tokio: $tokio:expr, async_io: $async_io:expr $(,)?) => { ... };
}
Expand description

Evaluates the tokio or async-io expression for the active backend.

With a single backend it resolves to that backend’s expression at compile time; with both it picks at runtime via use_tokio. The inactive arm is cfg-stripped, so each arm only needs to be valid in the configurations where its backend is compiled in.

The choice is re-evaluated on every call, so this is only safe where it doesn’t need to match a particular connection’s backend. A connection latches its backend once at build time (see Executor::new); use that instead of this macro for anything tied to the socket’s reactor. The current call sites (timers, the blocking pool) are independent of the socket, so a per-call decision is fine.