- 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
,java.lang.Runnable
public final class BatchEventProcessor<T> extends java.lang.Object implements EventProcessor
Convenience class for handling the batching semantics of consuming entries from aRingBuffer
and delegating the available events to anEventHandler
.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sequence
getSequence()
Get a reference to theSequence
being used by thisEventProcessor
.void
halt()
Signal that this EventProcessor should stop when it has finished consuming at the next clean break.boolean
isRunning()
void
run()
It is ok to have another thread rerun this method after a halt().void
setExceptionHandler(ExceptionHandler<? super T> exceptionHandler)
Set a newExceptionHandler
for handling exceptions propagated out of theBatchEventProcessor
.
-
-
-
Method Detail
-
getSequence
public Sequence getSequence()
Description copied from interface:EventProcessor
Get a reference to theSequence
being used by thisEventProcessor
.- Specified by:
getSequence
in interfaceEventProcessor
- Returns:
- reference to the
Sequence
for thisEventProcessor
-
halt
public void halt()
Description copied from interface:EventProcessor
Signal 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:
halt
in interfaceEventProcessor
-
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interfaceEventProcessor
- Returns:
- whether this event processor is running or not Implementations should ideally return false only when the associated thread is idle.
-
setExceptionHandler
public void setExceptionHandler(ExceptionHandler<? super T> exceptionHandler)
Set a newExceptionHandler
for 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:
run
in interfacejava.lang.Runnable
- Throws:
java.lang.IllegalStateException
- if this object instance is already running in a thread
-
-