disruptor.disruptor

An implementation of the Disruptor Pattern.

A disruptor is glorified ring buffer that allows multiple consumers to read its contents. This implementation is only threadsafe for a single producer. It differs from a normal single producer / multi consumer queue in the following points:

  • Slots are not distributed between consumers. Every consumer can consume each slot.
  • Slow consumer can catch up by consuming multiple slots at once.
  • Consumers can coordinate between each other by forming a dependency graph. If consumer A declares to depend on consumer B, it will only be able to read a slot after B has finished consuming it.

To interact with the disruptor a producer just calls Disruptor.produce, while consumers need to aquire a ConsumerToken first. The token tracks the current position of the consumer in the ringbuffer and on which other consumers it depends.

Members

Structs

ConsumerToken
struct ConsumerToken

ConsumerToken are used by consumers to interact with the Disruptor

Disruptor
struct Disruptor(T, ulong Size = nextPow2(10_000), ulong Consumers = 63)

A single-producer, multiple consumer disruptor implementation

Meta