pub struct ReactiveRuntime { /* private fields */ }Expand description
The process-wide reactive runtime. Construct via ReactiveRuntime::init
(once, on the UI thread) and reach later calls via ReactiveRuntime::get.
Implementations§
Source§impl ReactiveRuntime
impl ReactiveRuntime
Sourcepub fn init(waker: FrameWaker) -> &'static ReactiveRuntime
pub fn init(waker: FrameWaker) -> &'static ReactiveRuntime
Process-wide initialization (idempotent).
Must be called on the UI thread — the calling thread claims itself as
the owner of the local task queue that pump_local
drains. On the first call it builds the background tokio runtime, the
custom executor, and the root Owner. A second call (e.g. a relaunched
shell in the same process) does not rebuild anything: it re-marks the
current thread as the UI thread, replaces the waker so the new shell
re-owns wake-up, and returns the existing runtime. any_spawner’s
AlreadySet on a repeated executor install is expected and benign.
Sourcepub fn get() -> Option<&'static ReactiveRuntime>
pub fn get() -> Option<&'static ReactiveRuntime>
The installed runtime, if init has run.
Sourcepub fn with_owner<R>(&self, f: impl FnOnce() -> R) -> R
pub fn with_owner<R>(&self, f: impl FnOnce() -> R) -> R
Runs f under the root reactive Owner. Shells wrap their per-frame
rebuild in this so signals created during a rebuild are owned by the root
(and disposed only at process end).
Sourcepub fn pump_local(&self)
pub fn pump_local(&self)
Drains the UI-thread local task queue until it stalls, inside a tokio
runtime context so tokio::time::sleep in a local task registers with
the background runtime’s timer driver. Shells call this each loop turn.
Must be called on the UI thread (the one init ran on);
off-thread it pumps a distinct, empty queue.
Wasm: a harmless no-op drain of an always-empty queue. On this
target spawn_local routes to wasm_bindgen_futures::spawn_local
rather than this crate’s own local pool (see the module docs), so
there is nothing of this crate’s own for a shell to pump — it is still
safe (and, for cross-platform shell code, simplest) to call this every
loop turn on wasm too.
Sourcepub fn set_waker(&self, waker: FrameWaker)
pub fn set_waker(&self, waker: FrameWaker)
Replaces the frame waker (a relaunched shell re-owns wake-up).
Sourcepub fn wake(&self)
pub fn wake(&self)
Fires the current frame waker. Used by the executor’s spawn_local and
by the signals dirty-bridge.
Sourcepub fn take_signals_dirty(&self) -> bool
pub fn take_signals_dirty(&self) -> bool
Drains the signals-dirty flag: returns whether any tracked signal
changed since the last take_signals_dirty call, and clears it.
Ordering contract for shells: pump local tasks
(pump_local) FIRST, then call this — a
spawn_local continuation that writes a signal during the pump must
be observed by the same frame’s dirty check. Calling this before the
pump can miss a write a just-drained local task makes.
Sourcepub fn signals_dirty(&self) -> bool
pub fn signals_dirty(&self) -> bool
Non-draining peek at the signals-dirty flag (does not clear it).
Prefer take_signals_dirty for the actual
once-per-frame gate check; this is for tests/diagnostics that want to
observe the flag without consuming it.