T
- event implementation storing the details for the work to processed.public final class WorkProcessor<T> extends 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_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 boolean isRunning()
isRunning
in interface EventProcessor
public void run()
run
in interface Runnable
IllegalStateException
- if this processor is already runningCopyright © 2018. All rights reserved.