pub struct WakeBridge { /* private fields */ }Expand description
Coalesced cross-thread wake notifier shared by in-process async frontends (ReactiveRuntimeApp),
background workers, and the C ABI set_wake_callback hook.
Multiple trigger() / Waker::wake() calls before Self::take_pending coalesce into a
single host callback invocation so worker bursts never flood the UI event loop.
Self::clear_sink and Self::set_sink acquire the internal write lock before mutating
the callback slot, blocking until any in-flight callback invocation on another thread finishes
so host ctx pointers are never accessed after clearing or surface destruction.
Implementations§
Source§impl WakeBridge
impl WakeBridge
pub fn new() -> Self
Sourcepub fn defer_guard(&self) -> WakeDeferGuard<'_>
pub fn defer_guard(&self) -> WakeDeferGuard<'_>
Defers synchronous sink invocations until the returned WakeDeferGuard is dropped
(typically declared outside a surface write lock so wakes flush after unlock).
Sourcepub fn waker(self: &Arc<Self>) -> Waker
pub fn waker(self: &Arc<Self>) -> Waker
Creates a std::task::Waker backed directly by this WakeBridge.
Sourcepub fn detachable_waker(self: &Arc<Self>) -> (Waker, WakeToken)
pub fn detachable_waker(self: &Arc<Self>) -> (Waker, WakeToken)
Creates a std::task::Waker gated by an RAII WakeToken; dropping the token renders
all clones of that waker silent no-ops while still coalescing directly through this single
WakeBridge while alive.
Sourcepub fn set_sink(&self, cb: WakeCallback)
pub fn set_sink(&self, cb: WakeCallback)
Installs or replaces the host wake sink, waiting for any in-flight invocation of a prior
sink to return before replacing it (dropping any replaced sink after releasing the lock).
If a wake was already pending, invokes the installed sink once under the shared read lock
(or defers until any active Self::defer_guard exits).
Sourcepub fn set_sink_opt(&self, cb: Option<WakeCallback>)
pub fn set_sink_opt(&self, cb: Option<WakeCallback>)
Installs or clears the host wake sink from an Option<WakeCallback>.
Sourcepub fn clear_sink(&self)
pub fn clear_sink(&self)
Clears the installed host wake sink, waiting for any in-flight callback invocation on another thread to finish before returning (dropping the removed sink after unlocking).
Sourcepub fn trigger(&self)
pub fn trigger(&self)
Marks the bridge dirty and fires the installed sink on the false -> true transition while
holding the shared read lock so clear_sink()/destroy() cannot free host callback state
mid-call. Defers sink invocation while any WakeDeferGuard is active.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Returns whether a wake is currently pending without clearing the latch.
Sourcepub fn take_pending(&self) -> bool
pub fn take_pending(&self) -> bool
Clears and returns the coalesced pending flag after acquiring the surface write lock.