Skip to main content

HAS_TOKIO_REACTOR

Constant HAS_TOKIO_REACTOR 

Source
pub const HAS_TOKIO_REACTOR: bool = true;
Expand description

true when Reactor::spawn lands the future on the tokio runtime, false when it lands on the reactor-free background executor (exec_backend — the RTEMS target, or a host build with EPICS_RS_BUILD_EXEC_BACKEND=thread).

§What this is for

It is the exported form of build.rs’s backend decision, and the reason it is exported is that a spawned future’s access to a tokio reactor is decided here and consumed in other crates. A future handed to Reactor::spawn on exec_backend runs on a callback-pool worker with no reactor entered, so every tokio::net socket it opens panics — even in a process that has a tokio runtime somewhere else, because the runtime is not entered on that worker.

epics-ca-rs and epics-pva-rs therefore have to make the same decision this crate makes, for their own compilation, and they make it in their own build.rs from the same two inputs (target OS, EPICS_RS_BUILD_EXEC_BACKEND). That is three copies of one rule, so each of them pins the copy against this constant with a const assertion — a build where the two disagree, which now means one of the scripts did not see the variable, fails to compile instead of panicking at boot.