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.
| 构造器和说明 |
|---|
WorkProcessor(RingBuffer<T> ringBuffer,
SequenceBarrier sequenceBarrier,
WorkHandler<? super T> workHandler,
ExceptionHandler<? super T> exceptionHandler,
Sequence workSequence)
Construct a
WorkProcessor. |
| 限定符和类型 | 方法和说明 |
|---|---|
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 在接口中 EventProcessorSequence for this EventProcessorpublic void halt()
EventProcessorSequenceBarrier.alert() to notify the thread to check status.halt 在接口中 EventProcessorpublic boolean isRunning()
isRunning 在接口中 EventProcessorpublic void run()
run 在接口中 RunnableIllegalStateException - if this processor is already runningCopyright © 2018 Pivotal Software, Inc.. All rights reserved.