T
- event implementation storing the data for sharing during exchange or parallel coordination of an event.public final class BatchEventProcessor<T> extends java.lang.Object implements EventProcessor
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 and Description |
---|
BatchEventProcessor(DataProvider<T> ringBuffer,
SequenceBarrier sequenceBarrier,
EventHandler<T> eventHandler)
Construct a
EventProcessor that will automatically track the progress by updating its sequence when
the EventHandler.onEvent(Object, long, boolean) method returns. |
Modifier and Type | Method and Description |
---|---|
Sequence |
getSequence()
Get a reference to the
Sequence being used by this EventProcessor . |
void |
halt()
Signal that this EventProcessor should stop when it has finished consuming at the next clean break.
|
void |
run()
It is ok to have another thread rerun this method after a halt().
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
Set a new
ExceptionHandler for handling exceptions propagated out of the BatchEventProcessor |
public BatchEventProcessor(DataProvider<T> ringBuffer, SequenceBarrier sequenceBarrier, EventHandler<T> eventHandler)
EventProcessor
that will automatically track the progress by updating its sequence when
the EventHandler.onEvent(Object, long, boolean)
method returns.ringBuffer
- to which events are published.sequenceBarrier
- on which it is waiting.eventHandler
- is the delegate to which events are dispatched.public Sequence getSequence()
EventProcessor
Sequence
being used by this EventProcessor
.getSequence
in interface EventProcessor
Sequence
for this EventProcessor
public void halt()
EventProcessor
SequenceBarrier.alert()
to notify the thread to check status.halt
in interface EventProcessor
public void setExceptionHandler(ExceptionHandler exceptionHandler)
ExceptionHandler
for handling exceptions propagated out of the BatchEventProcessor
exceptionHandler
- to replace the existing exceptionHandler.public void run()
run
in interface java.lang.Runnable
java.lang.IllegalStateException
- if this object instance is already running in a threadCopyright © 2011 - 2013 LMAX Ltd. All Rights Reserved.