Skip to main content

ReorderingReceiver

Struct ReorderingReceiver 

Source
pub struct ReorderingReceiver<'a> { /* private fields */ }
Expand description

Ergonomic exact-delivery wrapper: pairs a stamped-ring consumer handle (PinnedRing) with a ReorderBuffer so a GlobalFifo (MergeByStamp) consumer receives items in exact stamp order without the MergeStrict watermark coupling or a Vyukov second CAS.

let pin = ring.pin_current_shape();
let mut rx = ReorderingReceiver::new(&pin, 0);
let mut out = [0u8; 56];
// steady state:
while let Some((len, stamp)) = rx.try_recv(&mut out) {
    deliver(&out[..len], stamp);
}
// end of stream - drain the buffered tail in order:
while let Some((len, stamp)) = rx.flush(&mut out) {
    deliver(&out[..len], stamp);
}

Implementations§

Source§

impl<'a> ReorderingReceiver<'a>

Source

pub fn new(pin: &'a PinnedRing<'a>, consumer_id: usize) -> Self

Wrap pin (a stamped-ring consumer handle) with the default adaptive window.

Source

pub fn with_window( pin: &'a PinnedRing<'a>, consumer_id: usize, floor: usize, cap: usize, ) -> Self

Wrap pin with an explicit floor/cap window (see ReorderBuffer::with_window).

Source

pub fn try_recv(&mut self, out: &mut [u8]) -> Option<(usize, u64)>

Pop one item from the ring into the buffer (if available), then release the next in-order item once the window is full. Returns (payload_len, stamp), or None while the window is still filling or the ring is momentarily empty. On end of stream, finish with flush.

Source

pub fn flush(&mut self, out: &mut [u8]) -> Option<(usize, u64)>

Drain the buffered tail in stamp order. Call in a loop after the producers have finished to release the last window items.

Source

pub fn corrections(&self) -> u64

Times the adaptive window had to grow (see ReorderBuffer::corrections).

Source

pub fn window(&self) -> usize

Current adaptive window.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ReorderingReceiver<'a>

§

impl<'a> !Send for ReorderingReceiver<'a>

§

impl<'a> !Sync for ReorderingReceiver<'a>

§

impl<'a> !UnwindSafe for ReorderingReceiver<'a>

§

impl<'a> Freeze for ReorderingReceiver<'a>

§

impl<'a> Unpin for ReorderingReceiver<'a>

§

impl<'a> UnsafeUnpin for ReorderingReceiver<'a>

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.