T - event implementation storing the details for the work to processed.public final class WorkProcessor<T> extends java.lang.Object implements EventProcessor
A WorkProcessor wraps a single WorkHandler, effectively consuming the sequence
and ensuring appropriate barriers.
Generally, this will be used as part of a WorkerPool.
| Constructor and Description |
|---|
WorkProcessor(RingBuffer<T> ringBuffer,
SequenceBarrier sequenceBarrier,
WorkHandler<? super T> workHandler,
ExceptionHandler<? super T> exceptionHandler,
Sequence workSequence)
Construct a
WorkProcessor. |
| 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.
|
boolean |
isRunning() |
void |
run()
It is ok to have another thread re-run this method after a halt().
|
public WorkProcessor(RingBuffer<T> ringBuffer, SequenceBarrier sequenceBarrier, WorkHandler<? super T> workHandler, ExceptionHandler<? super T> exceptionHandler, Sequence workSequence)
WorkProcessor.ringBuffer - to which events are published.sequenceBarrier - on which it is waiting.workHandler - is the delegate to which events are dispatched.exceptionHandler - to be called back when an error occursworkSequence - from which to claim the next event to be worked on. It should always be initialised
as Sequencer.INITIAL_CURSOR_VALUEpublic Sequence getSequence()
EventProcessorSequence being used by this EventProcessor.getSequence in interface EventProcessorSequence for this EventProcessorpublic void halt()
EventProcessorSequenceBarrier.alert() to notify the thread to check status.halt in interface EventProcessorpublic boolean isRunning()
isRunning in interface EventProcessorpublic void run()
run in interface java.lang.Runnablejava.lang.IllegalStateException - if this processor is already runningCopyright © 2011 - 2018 LMAX Ltd. All Rights Reserved.