Skip to main content

ReorderBuffer

Struct ReorderBuffer 

Source
pub struct ReorderBuffer { /* private fields */ }
Expand description

Bounded min-by-stamp reorder buffer with an adaptive window. See the module docs for the guarantee and the MergeStrict trade-off.

Implementations§

Source§

impl ReorderBuffer

Source

pub fn new() -> Self

A reorder buffer with the default floor/cap window.

Source

pub fn with_window(floor: usize, cap: usize) -> Self

A reorder buffer whose window starts at floor and grows (on a caught late stamp) up to cap. cap is clamped to at least floor.

Source

pub fn widen_to(&mut self, min_window: usize)

Proactively raise the window (and, if needed, the cap) to at least min_window. Called when the producer count GROWS at runtime: displacement is bounded by the concurrent producer count, so widening on growth keeps delivery provably exact instead of waiting for a caught late stamp (which admits one out-of-order release before the reactive growth kicks in).

Source

pub fn push(&mut self, stamp: u64, payload: &[u8])

Buffer one popped item (its stamp and payload). payload must fit in STAMPED_PAYLOAD_BYTES; longer input is truncated to that bound (the ring never delivers more than a stamped slot holds).

Source

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

Release the next in-order item into out if the buffer holds more than window items, returning its stamp and payload length. Returns None while the buffer is still filling the window (the steady-state call: push a pop, then try_take).

Source

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

Drain-time release: pop the next in-order item regardless of the window. Call in a loop after the source is exhausted to flush the tail in stamp order.

Source

pub fn len(&self) -> usize

Items currently buffered.

Source

pub fn is_empty(&self) -> bool

Whether the buffer holds no items.

Source

pub fn window(&self) -> usize

Current adaptive window size.

Source

pub fn corrections(&self) -> u64

How many times a late stamp forced the window to grow. Zero means the starting floor covered every observed displacement; see the module docs on reading this.

Trait Implementations§

Source§

impl Default for ReorderBuffer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.