Package com.lmax.disruptor.dsl
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);
}
-
ClassDescriptionProvides a repository mechanism to associate
EventHandlers withEventProcessorsDisruptor<T>A DSL-style API for setting up the disruptor pattern around a ring buffer (aka the Builder pattern).A group ofEventProcessors used as part of theDisruptor.A factory interface to make it possible to include custom event processors in a chain:Wrapper class to tie together a particular event processing stageA support class used as part of setting an exception handler for a specific event handler.A mutable exception handler wrapperDefines producer types to support creation of RingBuffer with correct sequencer and publisher.