pub struct NotificationHub { /* private fields */ }Expand description
Manages notification slots and the SPSC ring for a single reactor core.
Provides the end-to-end path from Ring 0 event emission to Ring 1 dispatch:
- Registration (Ring 2):
Self::register_sourceallocates a slot. - Notification (Ring 0):
Self::notify_sourceincrements the slot sequence and pushes aNotificationRefinto the SPSC ring. - Drain (Ring 1):
Self::drain_notificationspops all pending notifications.
Implementations§
Source§impl NotificationHub
impl NotificationHub
Sourcepub fn new(max_slots: usize, ring_capacity: usize) -> Self
pub fn new(max_slots: usize, ring_capacity: usize) -> Self
Creates a new notification hub.
§Arguments
max_slots— Maximum number of source slots (determines Vec capacity).ring_capacity— SPSC ring capacity (rounded up to power of 2).
Sourcepub fn register_source(&mut self) -> Option<u32>
pub fn register_source(&mut self) -> Option<u32>
Registers a new source and returns its source_id.
Returns None if the maximum slot count has been reached.
This is a Ring 2 operation (may allocate).
Sourcepub fn deactivate_source(&self, source_id: u32)
pub fn deactivate_source(&self, source_id: u32)
Marks the given source as inactive.
Inactive sources are skipped by Self::notify_source. The slot is not
deallocated — use NotificationSlot::reactivate to re-enable.
Sourcepub fn notify_source(
&self,
source_id: u32,
event_type: EventType,
row_count: u32,
timestamp: i64,
batch_offset: u64,
) -> bool
pub fn notify_source( &self, source_id: u32, event_type: EventType, row_count: u32, timestamp: i64, batch_offset: u64, ) -> bool
Notifies Ring 1 of a data change on the given source (Ring 0 hot path).
Increments the slot’s sequence counter and pushes a NotificationRef
into the SPSC ring. Returns false if:
- The
source_idis out of range - The slot is inactive
- The ring is full (backpressure)
Sourcepub fn drain_notifications<F: FnMut(NotificationRef)>(&self, f: F) -> usize
pub fn drain_notifications<F: FnMut(NotificationRef)>(&self, f: F) -> usize
Drains all pending notifications from the ring, calling f for each.
Returns the number of notifications drained. This is a Ring 1 operation.
Sourcepub fn notification_ring(&self) -> &NotificationRing
pub fn notification_ring(&self) -> &NotificationRing
Returns a reference to the underlying notification ring.
Sourcepub fn source_count(&self) -> usize
pub fn source_count(&self) -> usize
Returns the number of registered sources.
Sourcepub fn slot(&self, source_id: u32) -> Option<&NotificationSlot>
pub fn slot(&self, source_id: u32) -> Option<&NotificationSlot>
Returns a reference to the slot for the given source_id.
Auto Trait Implementations§
impl !Freeze for NotificationHub
impl !RefUnwindSafe for NotificationHub
impl Send for NotificationHub
impl Sync for NotificationHub
impl Unpin for NotificationHub
impl UnsafeUnpin for NotificationHub
impl UnwindSafe for NotificationHub
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more