pub struct DrainFanIn<S, const N: usize> { /* private fields */ }Expand description
Fixed-arity N→1 zero-copy merge over [S; N]. Round-robin fair; ends when
every source has drained. Shares the FSM shape of crate::pipe::fan_in::FanIn
(cursor + live-set + remaining) but drives sources push-style so items
borrow source slots without copying. No_std + no-alloc.
Implementations§
Source§impl<S, const N: usize> DrainFanIn<S, N>
impl<S, const N: usize> DrainFanIn<S, N>
Sourcepub fn live_count(&self) -> usize
pub fn live_count(&self) -> usize
Sources not yet permanently drained.
Sourcepub fn drain_each<F>(&mut self, visitor: F) -> DrainState
pub fn drain_each<F>(&mut self, visitor: F) -> DrainState
Visit the live sources once each, round-robin from the cursor, draining
each fully (the burst pattern: a source emits its ready items per visit,
then the next source). Items are read in-place — zero copy. Returns when
the visitor breaks (backpressure → DrainState::More, resuming at the
same source next call) or every source has drained.
Cross-call fairness: the cursor advances by one each call so a perpetually
busy source can’t permanently win the first slot. impl FnMut
monomorphises the consumer; the per-source drain_ready takes the
&mut dyn FnMut, so the only vtable hop is once per source, not per item.
Trait Implementations§
Source§impl<S: DrainSource, const N: usize> DrainSource for DrainFanIn<S, N>
impl<S: DrainSource, const N: usize> DrainSource for DrainFanIn<S, N>
Source§type Item = <S as DrainSource>::Item
type Item = <S as DrainSource>::Item
?Sized so it can be a [u8] slot view.Source§fn drain_ready(
&mut self,
visitor: &mut dyn FnMut(&Self::Item) -> ControlFlow<()>,
) -> DrainState
fn drain_ready( &mut self, visitor: &mut dyn FnMut(&Self::Item) -> ControlFlow<()>, ) -> DrainState
visitor on each (borrowed)
item in order. No alloc, no syscall, no waker on the hot path.