Expand description
Disruptor-inspired queue. The queue implemented in this module is based on a ring buffer, with producers and consumers accessing it in an orderly fashion.
Structs§
- Concurrent
Producer - A producer for a queue that can be concurrent with other (concurrent) producers
- Consumer
- A consumer of items from the queue
- Consumer
Access - An access to items from the queue through a consumer
- Multi
Barrier - A barrier to be used to await for the output of multiple other queue users, producer or consumers
- Owned
Output - The output of a single queue user The construction of producers and consumers guarantee a single writer
- Ring
Buffer - A circular queue to be accessed by producer(s) and consumers
- Sequence
- The position of an item in the queue.
This also uniquely identifies the item within the queue and is used by queue users to keep track of what items are still expected or consumed.
Sequence
has two usages: - Shared
Output - The common output for multiple queue users, usually concurrent producers
- Single
Barrier - A barrier to be used to await for the output of a single other queue user, producer or consumer
- Single
Producer - A single producer that will be the only producer for a queue
Enums§
- Consumer
Mode - The blocking mode for a consumer
Blocking consumers prevent producers from writing new items in the queue that would replace items not already seen by the consumer.
On the contrary, non-blocking consumers do not block producers, enabling producers to still write onto the queue.
Non-blocking consumers then run the risk of lagging behind. In that case trying to receive messages will produce
TryRecvError::Lagging
.
Traits§
- Output
- The output of a user of a queue, be it a producer or a consumer. For producers, this is the last sequence available to consumers. For consumers, this is the last item they finished handling that could then be seen by other downchain consumers.
- Queue
User - The user of a queue, be it a producer or a consumer
This trait abstracts over producers and consumers so that the associated
UserOutput
can be retrieved. TheUserOutput
can be used in turn to await items published by the queue user. This enables the construction of consumers that await the items directly from producer, but also from one or more other producers using an appropriateBarrier
.