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
impl ReorderBuffer
Sourcepub fn with_window(floor: usize, cap: usize) -> Self
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.
Sourcepub fn widen_to(&mut self, min_window: usize)
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).
Sourcepub fn push(&mut self, stamp: u64, payload: &[u8])
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).
Sourcepub fn try_take(&mut self, out: &mut [u8]) -> Option<(u64, usize)>
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).
Sourcepub fn flush_one(&mut self, out: &mut [u8]) -> Option<(u64, usize)>
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.
Sourcepub fn corrections(&self) -> u64
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.