pub struct Buffer<T> { /* private fields */ }
Expand description
Buffering mechanism for Temporal
data
This struct is a Consumer
and Producer
which forwards data from a
connected Producer
to all connected Consumer
s while performing
buffering.
This block may also be used to “suck” parasitic buffers empty. As each
flow::Sender
has a capacity of 1
(see underlying broadcast_bp
channel), a chain of blocks may accumulate a significant buffer volume.
This may be unwanted.
By placing a Buffer
block near the end of the chain and providing a
max_age
argument equal to or smaller than max_capacity
to
Buffer::new
, the buffer block will consume (and discard) data even when
its connected consumer isn’t fast enough.
Implementations
sourceimpl<T> Buffer<T>where
T: Clone + Send + Sync + 'static,
T: Temporal,
impl<T> Buffer<T>where
T: Clone + Send + Sync + 'static,
T: Temporal,
sourcepub fn new(
initial_capacity: f64,
min_capacity: f64,
max_capacity: f64,
max_age: f64
) -> Self
pub fn new(
initial_capacity: f64,
min_capacity: f64,
max_capacity: f64,
max_age: f64
) -> Self
Create new Buffer
The buffer will start with buffering initial_capacity
seconds of
data before beginning to send out received data.
When empty, the buffer will buffer data corresponding to a duration of
at least min_capacity
seconds before sending out data again.
It will suspend receiving when holding strictly more than
max_capacity
seconds of data.
If buffered data is held longer than max_age
seconds, it will be
discarded.
Trait Implementations
sourceimpl<T> Consumer<T> for Buffer<T>
impl<T> Consumer<T> for Buffer<T>
sourcefn receiver_connector(&self) -> &ReceiverConnector<T>
fn receiver_connector(&self) -> &ReceiverConnector<T>
ReceiverConnector
sourcefn feed_from_none(&self)
fn feed_from_none(&self)
Consumer
from any connected Producer
if connectedsourcefn connect_to_producer<P: Producer<T>>(&self, producer: &P)
fn connect_to_producer<P: Producer<T>>(&self, producer: &P)
feed_from
Consumer
to Producer
sourcefn disconnect_from_producer(&self)
fn disconnect_from_producer(&self)
feed_from_none
Consumer
from any connected Producer
if connectedsourceimpl<T> Producer<T> for Buffer<T>
impl<T> Producer<T> for Buffer<T>
sourcefn sender_connector(&self) -> &SenderConnector<T>
fn sender_connector(&self) -> &SenderConnector<T>
SenderConnector
sourcefn connect_to_consumer<C: Consumer<T>>(&self, consumer: &C)
fn connect_to_consumer<C: Consumer<T>>(&self, consumer: &C)
feed_into
Producer
to Consumer