Skip to main content

LocalNotify

Struct LocalNotify 

Source
pub struct LocalNotify { /* private fields */ }
Expand description

Single-threaded notification with per-token dedup.

Mirrors event_queue semantics for single-threaded use. Tokens are registered, marked as changed, and polled. Each token appears at most once per poll cycle.

The interest/subscription layer (mapping data sources to reactors) is a higher-level concern handled by the consumer (e.g., the reactor system in nexus-rt).

Implementations§

Source§

impl LocalNotify

Source

pub fn with_capacity(capacity: usize) -> Self

Create with an initial capacity hint. Grows as needed.

Source

pub fn register(&mut self) -> Token

Register a new token. Returns its identifier.

Grows the dedup bitset if needed.

Source

pub fn ensure_capacity(&mut self, idx: usize)

Ensure the bitset can hold a token at the given index.

Use this when token indices are managed externally (e.g., by a slab) and may not be sequential. Grows the bitset and updates the high-water mark if needed.

Source

pub fn mark(&mut self, token: Token)

Mark a token as changed this cycle.

If the token is already marked (deduped), this is a no-op.

§Panics

Panics if token.index() >= num_tokens (unregistered token).

Source

pub fn poll(&mut self, events: &mut Events)

Drain all marked tokens into the events buffer.

The events buffer is cleared then filled. Tokens appear in mark order. After polling, all dedup state is cleared — ready for the next cycle.

Mirrors Poller::poll.

Source

pub fn poll_limit(&mut self, events: &mut Events, limit: usize)

Drain up to limit marked tokens into the events buffer.

Remaining tokens stay queued for the next poll call. Tokens appear in mark order (FIFO).

Mirrors Poller::poll_limit.

Source

pub fn has_notified(&self) -> bool

Returns true if any token is marked.

Source

pub fn notified_count(&self) -> usize

Number of tokens currently marked.

Source

pub fn capacity(&self) -> usize

Number of registered tokens.

Trait Implementations§

Source§

impl Debug for LocalNotify

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.