Skip to main content

SharedRingMpmc

Struct SharedRingMpmc 

Source
pub struct SharedRingMpmc;
Expand description

Factory for an MPMC grid composed from N Lamport SPSC rings partitioned across M consumers.

Implementations§

Source§

impl SharedRingMpmc

Source

pub fn create_anon_grid( n_producers: usize, n_consumers: usize, capacity: usize, ) -> Result<(Vec<MpmcProducer>, Vec<MpmcConsumer>), RingError>

Anonymous in-memory MPMC grid: n_producers rings, n_consumers consumer handles. Consumer i drains producer rings i, i + n_consumers, i + 2*n_consumers, and so on.

Constraints: n_consumers >= 1, n_producers >= n_consumers (so every consumer has at least one ring; idle consumers are a configuration smell, not a feature).

Source

pub fn create_grid_in_region<R: RegionOwner>( region: R, n_producers: usize, n_consumers: usize, capacity: usize, ) -> Result<(Vec<MpmcProducer>, Vec<MpmcConsumer>), RingError>

MPMC grid laid out in ONE caller-owned region (huge / large pages). All n_producers SPSC lanes are carved back-to-back from the single region, so the whole grid sits on a handful of 2 MB / 1 GB pages instead of n_producers separate small mappings - the case where large pages actually shed TLB pressure. The region must hold at least spsc_ring_file_size(capacity) * n_producers bytes.

This is the per-producer-FIFO MPMC primitive on large pages; SharedRing::create_in_region is the global-FIFO (Vyukov) counterpart.

Source

pub fn create_grid( path_prefix: impl AsRef<Path>, n_producers: usize, n_consumers: usize, capacity: usize, ) -> Result<(Vec<MpmcProducer>, Vec<MpmcConsumer>), RingError>

File-backed MPMC grid: one file per producer ring; the file path for ring i is path_prefix.{i}.bin.

Source

pub fn open_grid( path_prefix: impl AsRef<Path>, n_producers: usize, n_consumers: usize, expected_capacity: usize, ) -> Result<(Vec<MpmcProducer>, Vec<MpmcConsumer>), RingError>

Open an existing file-backed grid.

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.