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
impl LocalNotify
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with an initial capacity hint. Grows as needed.
Sourcepub fn register(&mut self) -> Token
pub fn register(&mut self) -> Token
Register a new token. Returns its identifier.
Grows the dedup bitset if needed.
Sourcepub fn ensure_capacity(&mut self, idx: usize)
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.
Sourcepub fn mark(&mut self, token: Token)
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).
Sourcepub fn poll(&mut self, events: &mut Events)
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.
Sourcepub fn poll_limit(&mut self, events: &mut Events, limit: usize)
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.
Sourcepub fn has_notified(&self) -> bool
pub fn has_notified(&self) -> bool
Returns true if any token is marked.
Sourcepub fn notified_count(&self) -> usize
pub fn notified_count(&self) -> usize
Number of tokens currently marked.