pub enum OverflowPolicy {
Block(Duration),
DropNewest,
}Expand description
What a Queue does when its channel is full.
Variants§
Block(Duration)
Block the pushing thread until there’s room, up to Duration —
the right choice for offline/file processing, where correctness
matters more than staying caught up. Use Duration::MAX (what
OverflowPolicy::default does) for what’s practically an
unbounded wait — [Sender::send_timeout] with that duration
isn’t ever going to time out in a real program.
A finite Duration is the escape hatch against the one thing
an actually-unbounded wait can’t recover from: whatever’s
downstream not just falling behind (ordinary backpressure, which
resolves on its own as the worker keeps draining) but genuinely
stuck — a Sink::consume call somewhere in the chain that never
returns. An unbounded wait here would then also wedge whoever’s
pushing into this Queue, and transitively every Queue
upstream of that, since each one’s worker can’t get back to its
own control_rx until its current downstream.consume() call
returns (see Queue::control’s own docs on why control is only
ever checked between buffers, not able to preempt one already
in flight). Timing out bounds that: it’s what lets a Stop sent
to an upstream Queue eventually reach it instead of waiting
forever. Doesn’t help if the stall is inside a raw (non-Queue)
Sink’s own consume() call directly — nothing here retries or
times out that call itself, only the channel send. On timeout,
returns QueueError::SendTimedOut rather than losing the
buffer silently — unlike OverflowPolicy::DropNewest, this
isn’t an expected, routine condition.
This timeout applies to ordinary data buffers only. Queue sends
MediaBuffer::Eos with an unbounded send under every policy so a
natural end-of-stream marker is never discarded; if downstream has
stopped consuming entirely, an EOS push can therefore still block.
DropNewest
Drop the incoming buffer instead of blocking, and post
BusEvent::Dropped. Never stalls the upstream thread — the
right choice for live sources, where falling behind is worse than
losing a frame.
Trait Implementations§
Source§impl Clone for OverflowPolicy
impl Clone for OverflowPolicy
Source§fn clone(&self) -> OverflowPolicy
fn clone(&self) -> OverflowPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more