Module com.lmax.disruptor
Package com.lmax.disruptor.dsl
A DSL-style API for setting up the disruptor pattern around a ring buffer.
Example code
// Specify the size of the ring buffer, must be power of 2.
int bufferSize = 1024;
// Construct the Disruptor
Disruptor<LongEvent> disruptor = new Disruptor<>(LongEvent::new, bufferSize, DaemonThreadFactory.INSTANCE);
// Connect the handler
disruptor.handleEventsWith((event, sequence, endOfBatch) -> System.out.println("Event: " + event));
// Start the Disruptor, starts all threads running
disruptor.start();
// Get the ring buffer from the Disruptor to be used for publishing.
RingBuffer<LongEvent> ringBuffer = disruptor.getRingBuffer();
ByteBuffer bb = ByteBuffer.allocate(8);
for (long l = 0; true; l++)
{
bb.putLong(0, l);
ringBuffer.publishEvent((event, sequence, buffer) -> event.set(buffer.getLong(0)), bb);
Thread.sleep(1000);
}
-
Interface Summary Interface Description EventProcessorFactory<T> A factory interface to make it possible to include custom event processors in a chain: -
Class Summary Class Description Disruptor<T> A DSL-style API for setting up the disruptor pattern around a ring buffer (aka the Builder pattern).EventHandlerGroup<T> A group ofEventProcessor
s used as part of theDisruptor
.ExceptionHandlerSetting<T> A support class used as part of setting an exception handler for a specific event handler.ExceptionHandlerWrapper<T> A mutable exception handler wrapper -
Enum Summary Enum Description ProducerType Defines producer types to support creation of RingBuffer with correct sequencer and publisher.