Skip to main content

WakeBridge

Struct WakeBridge 

Source
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

Source

pub fn new() -> Self

Source

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

Source

pub fn waker(self: &Arc<Self>) -> Waker

Creates a std::task::Waker backed directly by this WakeBridge.

Source

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.

Source

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

Source

pub fn set_sink_opt(&self, cb: Option<WakeCallback>)

Installs or clears the host wake sink from an Option<WakeCallback>.

Source

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

Source

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.

Source

pub fn is_pending(&self) -> bool

Returns whether a wake is currently pending without clearing the latch.

Source

pub fn take_pending(&self) -> bool

Clears and returns the coalesced pending flag after acquiring the surface write lock.

Trait Implementations§

Source§

impl Default for WakeBridge

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Wake for WakeBridge

Source§

fn wake(self: Arc<Self>)

Wake this task.
Source§

fn wake_by_ref(self: &Arc<Self>)

Wake this task without consuming the waker. Read more

Auto Trait Implementations§

§

impl !Freeze for WakeBridge

§

impl Forget for WakeBridge

§

impl Move for WakeBridge

§

impl RefUnwindSafe for WakeBridge

§

impl Send for WakeBridge
where Atomic<bool>: Send, Atomic<usize>: Send, RwLock<Option<Arc<dyn Fn() + Send + Sync>>>: Send,

§

impl Sync for WakeBridge
where Atomic<bool>: Sync, Atomic<usize>: Sync, RwLock<Option<Arc<dyn Fn() + Send + Sync>>>: Sync,

§

impl Unpin for WakeBridge
where Align1<u8>: Unpin, Align8<usize>: Unpin, Align4<u32>: Unpin, Arc<dyn Fn() + Send + Sync>: Unpin,

§

impl UnsafeUnpin for WakeBridge
where Align1<u8>: UnsafeUnpin, Align8<usize>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, *const ArcInner<dyn Fn() + Send + Sync> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Fn() + Send + Sync>>: UnsafeUnpin,

§

impl UnwindSafe for WakeBridge
where Align1<u8>: UnwindSafe, Align8<usize>: UnwindSafe, RwLock<Option<Arc<dyn Fn() + Send + Sync>>>: UnwindSafe,

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