Expand description
Data flow between signal processing blocks
Overview
This module provides an extension to the broadcast_bp
channel.
Like broadcast_bp
, a type argument T
is used to select the type of the
passed values. However, only types which implement the Message
trait
can be used by this module.
Opposed to broadcast_bp
, this module allows Receiver
s to be
(re-)connected to different Sender
s after creation and use.
For that, each Sender
has an associated SenderConnector
and each
Receiver
has an associated ReceiverConnector
. The connectors provide
methods to (re-)connect their associated Sender
s and Receiver
s.
Moreover, two traits Producer
and Consumer
are provided, which
describe data types that produce or consume data using a background task
and which contain a SenderConnector
or ReceiverConnector
, respectively,
such that it’s possible to connect Producer
s and Consumer
s with each
other.
Upon disconnection, a special value is optionally inserted into the stream
of received values. This value is determined by the
Message::disconnection
method.
Implementing a Producer
or Consumer
Upon creation, Producer
s use the new_sender
function to create a pair
consisting of a Sender
and a SenderConnector
. The Sender
is passed to
a background task while the SenderConnector
is stored and accessible
through the Producer::sender_connector
method.
Consumers
use the new_receiver
function upon creation to create a
pair of a Receiver
and a ReceiverConnector
. The Receiver
is passed to
a background task while the ReceiverConnector
is stored and accessible
through the Consumer::receiver_connector
method.
Refer to the source code of the Nop
block for an example.
Buffering and Congestion
Connecting a Producer
to more than one Consumer
at the same time will
stall all involved blocks if one of the Consumer
s is stalled; i.e. all
Consumer
s must process the data in order for the Producer
to be able to
send further data.
There is a buffer capacity of 1
for each Sender
/Producer
. Because of
this, longer chains may lead to a significant buffer volume.
The blocks
module uses the Buffer
block for tweaking buffering
behavior, including dropping data in case of congestion and countermeasures
against latency.
Re-exports
pub use crate::sync::broadcast_bp::channel as new_sender;
pub use crate::sync::broadcast_bp::Enlister as SenderConnector;
pub use crate::sync::broadcast_bp::RecvError;
pub use crate::sync::broadcast_bp::Reservation;
pub use crate::sync::broadcast_bp::RsrvError;
pub use crate::sync::broadcast_bp::SendError;
pub use crate::sync::broadcast_bp::Sender;
Structs
Message
, which doesn’t provide a value that
indicates disconnectionTraits
ReceiverConnector
and can be connected to a
Producer
SenderConnector
and can be connected to a
Consumer
Functions
Receiver
with an associated ReceiverConnector