Skip to main content

SharedBroadcastRing

Struct SharedBroadcastRing 

Source
pub struct SharedBroadcastRing { /* private fields */ }

Implementations§

Source§

impl SharedBroadcastRing

Source

pub fn create( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, BroadcastError>

File-backed broadcast ring; cross-process visibility via the OS page cache. Obtains the ring at path: it initializes an empty one only when the path does not yet exist, and otherwise attaches with published slots and versions intact. A region built with a different capacity is a LayoutMismatch. reset reinitializes.

Source

pub fn reset( path: impl AsRef<Path>, capacity: usize, ) -> Result<Self, BroadcastError>

Truncate the ring at path and initialize an empty one, discarding every published slot live peers share. For a caller that knows it owns the path.

Source

pub fn create_anon(capacity: usize) -> Result<Self, BroadcastError>

Anonymous in-process broadcast ring. Fastest construction; skips file create + ftruncate + first-page-fault. In-process only - subscribers in other processes cannot connect.

Source

pub fn open( path: impl AsRef<Path>, expected_capacity: usize, ) -> Result<Self, BroadcastError>

Open an existing file-backed broadcast ring. Validates magic + capacity.

Source

pub fn create_from_shm( shm: ShmFile, capacity: usize, ) -> Result<Self, BroadcastError>

Build a fresh broadcast ring on top of a named RAM-resident shared-memory backing. Cross-process visible via the logical_name of the underlying ShmFile; never touches the page cache. The ShmFile must be sized to at least broadcast_file_size(capacity) bytes.

Source

pub fn open_from_shm( shm: ShmFile, expected_capacity: usize, ) -> Result<Self, BroadcastError>

Open an existing named ShmFs-backed broadcast ring. Validates magic + capacity. Does NOT re-initialise the layout - the layout must already be present from a prior create_from_shm on the same logical name.

Source

pub fn capacity(&self) -> usize

Source

pub fn register_consumer(&self) -> Result<usize, BroadcastError>

Register as a consumer. Returns a consumer index in 0..MAX_CONSUMERS; that index is used for all subsequent recv calls. Initialises the consumer’s cursor to the current producer_seq (consumer starts reading from “now,” not history).

Source

pub fn unregister_consumer(&self, consumer_idx: usize)

Unregister a consumer. After this, the producer no longer waits for this cursor when reclaiming slots.

Source

pub fn try_push(&self, payload: &[u8]) -> Result<(), BroadcastError>

Push a message. Returns Err(Full) when at least one active consumer hasn’t yet read a previous slot we’d overwrite.

Source

pub fn try_recv( &self, consumer_idx: usize, out: &mut [u8], ) -> Result<usize, BroadcastError>

Receive the next unread message for consumer_idx. Returns the number of bytes filled (always BROADCAST_PAYLOAD_BYTES; caller knows the inner-event size from its T contract).

Source

pub fn lag(&self, consumer_idx: usize) -> u64

Number of messages this consumer has not yet read.

Source

pub fn producer_position(&self) -> u64

Current producer cursor (total messages pushed since creation).

Source

pub fn active_consumer_count(&self) -> usize

Number of currently active consumers.

Source

pub fn flush(&self) -> Result<(), BroadcastError>

Source

pub fn flush_async(&self) -> Result<(), BroadcastError>

Non-blocking flush: schedules a writeback via the OS. Note: Windows is only partially async (sync to page cache, not to disk).

Source

pub fn is_fully_drained(&self) -> bool

Whether every currently-active consumer has read every item the producer has published. Used by the capacity-morph wrapper to decide whether a stale broadcast backing can be dropped (all subscribers have caught up to the frozen producer position).

Trait Implementations§

Source§

impl AdaptiveInstance for SharedBroadcastRing

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.
Source§

impl Send for SharedBroadcastRing

Source§

impl Sync for SharedBroadcastRing

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.