Expand description
§Ansa
Multithreaded, lock-free queue implementation using the Disruptor pattern.
todo
to mention:
- no panics outside of the convenience functions
- sequence limit (i64::MAX)
- Basics of how the disruptor works
- traffic jam analogy
- features
- examples
- terminology (ring buffer, handle, etc…)
§Disruptor
This crate implements the Disruptor pattern as described in the original whitepaper.
In particular, section 4.3 Sequencing provides a complete description of how accesses to the
buffer are synchronised. It is not an understatement to say that understanding just section 4.3
of the paper is enough to understand the Disruptor pattern as a whole.
A disruptor is made up of three components:
- A ring buffer (aka circular buffer, aka buffer).
- A lead producer handle which follows the last of the trailing handles.
- Any number of consumer and producer handles which trail the lead, and which may be structured into a directed acyclic graph.
The buffer is pre-populated with events when a disruptor is created.
As their names suggest, produces have mutable access to events on the buffer, while consumers have only immutable access.
Every handle is limited in what portion of the buffer it can access by the handles it follows.
A handle h cannot overtake the handles B (for barrier) that it follows. This constraint
is ensures buffer accesses do not invalidly overlap.
Modules§
- wait
- Provides strategies used by handles when waiting for sequences on the ring buffer.
Structs§
- Barrier
- A collection of cursors that determine which sequence is available to a handle.
- Consumer
- A handle with immutable access to events on the ring buffer.
- Disruptor
Builder - Configures and builds the buffer and handles for a single disruptor.
- Disruptor
Handles - Holds the producers and consumers for a single disruptor.
- Events
- A batch of events which may be immutably accessed.
- Events
Mut - A batch of events which may be mutably accessed.
- Multi
Producer - A handle with mutable access to events on the ring buffer.
- Producer
- A handle with mutable access to events on the ring buffer.
Enums§
- Build
Error - Describes the possible errors encountered when building a disruptor.
- Follows
- Describes the ordering relationship for a single handle.
- Handle
- Describes the type of handle.