com.lmax.disruptor
Class WorkProcessor<T>

java.lang.Object
  extended by com.lmax.disruptor.WorkProcessor<T>
Type Parameters:
T - event implementation storing the details for the work to processed.
All Implemented Interfaces:
EventProcessor, java.lang.Runnable

public final class WorkProcessor<T>
extends java.lang.Object
implements EventProcessor

WorkProcessor for ensuring each sequence is handled by only a single processor, effectively consuming the sequence. No other WorkProcessors in the WorkerPool will consume the same sequence.


Constructor Summary
WorkProcessor(RingBuffer<T> ringBuffer, SequenceBarrier sequenceBarrier, WorkHandler<T> workHandler, ExceptionHandler exceptionHandler, Sequence workSequence)
          Construct a WorkProcessor.
 
Method Summary
 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().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkProcessor

public WorkProcessor(RingBuffer<T> ringBuffer,
                     SequenceBarrier sequenceBarrier,
                     WorkHandler<T> workHandler,
                     ExceptionHandler exceptionHandler,
                     Sequence workSequence)
Construct a WorkProcessor.

Parameters:
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 occurs
workSequence - from which to claim the next event to be worked on. It should always be initialised as Sequencer.INITIAL_CURSOR_VALUE
Method Detail

getSequence

public Sequence getSequence()
Description copied from interface: EventProcessor
Get a reference to the Sequence being used by this EventProcessor.

Specified by:
getSequence in interface EventProcessor
Returns:
reference to the Sequence for this EventProcessor

halt

public void halt()
Description copied from interface: EventProcessor
Signal that this EventProcessor should stop when it has finished consuming at the next clean break. It will call SequenceBarrier.alert() to notify the thread to check status.

Specified by:
halt in interface EventProcessor

run

public void run()
It is ok to have another thread re-run this method after a halt().

Specified by:
run in interface java.lang.Runnable


Copyright © 2011 LMAX Ltd. All Rights Reserved.