Class WorkProcessor<T>

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

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.

  • Field Details

  • Constructor Details

    • WorkProcessor

      public WorkProcessor(RingBuffer<T> ringBuffer, SequenceBarrier sequenceBarrier, WorkHandler<? super T> workHandler, ExceptionHandler<? super T> 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 Details

    • 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
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning 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 Runnable
      Throws:
      IllegalStateException - if this processor is already running
    • notifyTimeout

      private void notifyTimeout(long availableSequence)
    • notifyStart

      private void notifyStart()
    • notifyShutdown

      private void notifyShutdown()