Skip to main content

SharedRingMpscFifo

Struct SharedRingMpscFifo 

Source
pub struct SharedRingMpscFifo;
Expand description

Factory for a single-ring MPSC pool that preserves global FIFO ordering across all producers. Producers contend on one Vyukov-MPMC producer_seq (CAS retries on push) while the single consumer skips the consumer-side CAS by using the try_pop_spsc fast path on the underlying SharedRing.

§When this beats SharedRingMpsc (the composed variant)

SharedRingMpsc is faster on the producer side for any N because each producer owns its own ring (zero CAS contention). SharedRingMpscFifo wins on the consumer side because the consumer drains one ring instead of round-robining N. The crossover depends on:

  • N (producer count): low N favours Fifo (light producer CAS contention + no consumer round-robin); high N favours Composed (independent producer rings, no shared CAS).
  • ordering requirement: Fifo is the only choice when the caller needs global FIFO across all producers (e.g. a totally- ordered event log). Composed only preserves per-producer FIFO.

examples/mpmc_shootout.rs benches both side by side at common (N producers, 1 consumer) shapes; pick by measurement.

Implementations§

Source§

impl SharedRingMpscFifo

Source

pub fn create_anon_pool( n_producers: usize, capacity: usize, ) -> Result<(Vec<MpscFifoProducer>, MpscFifoConsumer), RingError>

Anonymous in-memory single-ring MPSC pool.

Source

pub fn create_pool( path: impl AsRef<Path>, n_producers: usize, capacity: usize, ) -> Result<(Vec<MpscFifoProducer>, MpscFifoConsumer), RingError>

File-backed single-ring MPSC pool. One backing file (not one per producer), so cross-process layout is identical to a single SharedRing.

Source

pub fn open_pool( path: impl AsRef<Path>, n_producers: usize, expected_capacity: usize, ) -> Result<(Vec<MpscFifoProducer>, MpscFifoConsumer), RingError>

Open an existing file-backed single-ring MPSC pool.

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.