T
- event implementation storing the details for the work to processed.public final class WorkProcessor<T> extends java.lang.Object implements EventProcessor
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<T> workHandler,
ExceptionHandler 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.
|
void |
run()
It is ok to have another thread re-run this method after a halt().
|
public WorkProcessor(RingBuffer<T> ringBuffer, SequenceBarrier sequenceBarrier, WorkHandler<T> workHandler, ExceptionHandler 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_VALUE
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 run()
run
in interface java.lang.Runnable
java.lang.IllegalStateException
- if this processor is already runningCopyright © 2011 - 2013 LMAX Ltd. All Rights Reserved.