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 UnwindSafe for NotificationHub
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.