Expand description
Special channel construction to distribute data from various inputs into N outputs minimizing buffering but preventing deadlocks when repartitioning
Β§Design
+----+ +------+
| TX |==|| | Gate |
+----+ || | | +--------+ +----+
====| |==| Buffer |==| RX |
+----+ || | | +--------+ +----+
| TX |==|| | |
+----+ | |
| |
+----+ | | +--------+ +----+
| TX |======| |==| Buffer |==| RX |
+----+ +------+ +--------+ +----+There are N virtual MPSC (multi-producer, single consumer) channels with unbounded capacity. However, if all
buffers/channels are non-empty, than a global gate will be closed preventing new data from being written (the
sender futures will be pending) until at least one channel is empty (and not closed).
StructsΒ§
- Channel π
- Links senders and receivers.
- Channel
State π - Distribution
Receiver - Receiver side of distribution channels.
- Distribution
Sender - Sender side of distribution channels.
- Gate π
- The βall channels have dataβ gate.
- Recv
Future - Future backing recv.
- Send
Error - Erroring during send.
- Send
Future - Future backing send.
FunctionsΒ§
- channels
- Create
nempty channels. - partition_
aware_ channels - Create
n_outempty channels for each of then_ininputs. This way, each distinct partition will communicate via a dedicated channel. This SPSC structure enables us to track which partition input data comes from.
Type AliasesΒ§
- Partition
Aware πReceivers - Partition
Aware πSenders - Shared
Channel π - Shared channel.
- Shared
Gate π - Gate shared by all senders and receivers.