Skip to main content

ReactiveRuntime

Struct ReactiveRuntime 

Source
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

Source

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.

Source

pub fn get() -> Option<&'static ReactiveRuntime>

The installed runtime, if init has run.

Source

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).

Source

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.

Source

pub fn set_waker(&self, waker: FrameWaker)

Replaces the frame waker (a relaunched shell re-owns wake-up).

Source

pub fn wake(&self)

Fires the current frame waker. Used by the executor’s spawn_local and by the signals dirty-bridge.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> StorageAccess<T> for T

Source§

fn as_borrowed(&self) -> &T

Borrows the value.
Source§

fn into_taken(self) -> T

Takes the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.