Class BatchEventProcessor<T>
java.lang.Object
com.lmax.disruptor.BatchEventProcessor<T>
- Type Parameters:
T- event implementation storing the data for sharing during exchange or parallel coordination of an event.
- All Implemented Interfaces:
EventProcessor, Runnable
Convenience class for handling the batching semantics of consuming entries from a
RingBuffer
and delegating the available events to an EventHandler.
If the EventHandler also implements LifecycleAware it will be notified just after the thread
is started and just before the thread is shutdown.
-
Constructor Summary
ConstructorsConstructorDescriptionBatchEventProcessor(DataProvider<T> dataProvider, SequenceBarrier sequenceBarrier, EventHandler<? super T> eventHandler) Construct aEventProcessorthat will automatically track the progress by updating its sequence when theEventHandler.onEvent(Object, long, boolean)method returns. -
Method Summary
Modifier and TypeMethodDescriptionGet a reference to theSequencebeing used by thisEventProcessor.voidhalt()Signal that this EventProcessor should stop when it has finished consuming at the next clean break.booleanvoidrun()It is ok to have another thread rerun this method after a halt().voidsetExceptionHandler(ExceptionHandler<? super T> exceptionHandler) Set a newExceptionHandlerfor handling exceptions propagated out of theBatchEventProcessor
-
Constructor Details
-
BatchEventProcessor
public BatchEventProcessor(DataProvider<T> dataProvider, SequenceBarrier sequenceBarrier, EventHandler<? super T> eventHandler) Construct aEventProcessorthat will automatically track the progress by updating its sequence when theEventHandler.onEvent(Object, long, boolean)method returns.- Parameters:
dataProvider- to which events are published.sequenceBarrier- on which it is waiting.eventHandler- is the delegate to which events are dispatched.
-
-
Method Details
-
getSequence
Description copied from interface:EventProcessorGet a reference to theSequencebeing used by thisEventProcessor.- Specified by:
getSequencein interfaceEventProcessor- Returns:
- reference to the
Sequencefor thisEventProcessor
-
halt
public void halt()Description copied from interface:EventProcessorSignal that this EventProcessor should stop when it has finished consuming at the next clean break. It will callSequenceBarrier.alert()to notify the thread to check status.- Specified by:
haltin interfaceEventProcessor
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceEventProcessor
-
setExceptionHandler
Set a newExceptionHandlerfor handling exceptions propagated out of theBatchEventProcessor- Parameters:
exceptionHandler- to replace the existing exceptionHandler.
-
run
public void run()It is ok to have another thread rerun this method after a halt().- Specified by:
runin interfaceRunnable- Throws:
IllegalStateException- if this object instance is already running in a thread
-