Class AbstractSequencer

java.lang.Object
com.lmax.disruptor.AbstractSequencer
All Implemented Interfaces:
Cursored, Sequenced, Sequencer
Direct Known Subclasses:
MultiProducerSequencer, SingleProducerSequencerPad

public abstract class AbstractSequencer extends Object implements Sequencer
Base class for the various sequencer types (single/multi). Provides common functionality like the management of gating sequences (add/remove) and ownership of the current cursor.
  • Field Details

  • Constructor Details

    • AbstractSequencer

      public AbstractSequencer(int bufferSize, WaitStrategy waitStrategy)
      Create with the specified buffer size and wait strategy.
      Parameters:
      bufferSize - The total number of entries, must be a positive power of 2.
      waitStrategy - The wait strategy used by this sequencer
  • Method Details

    • getCursor

      public final long getCursor()
      Description copied from interface: Cursored
      Get the current cursor value.
      Specified by:
      getCursor in interface Cursored
      Returns:
      current cursor value
      See Also:
    • getBufferSize

      public final int getBufferSize()
      Description copied from interface: Sequenced
      The capacity of the data structure to hold entries.
      Specified by:
      getBufferSize in interface Sequenced
      Returns:
      the size of the RingBuffer.
      See Also:
    • addGatingSequences

      public final void addGatingSequences(Sequence... gatingSequences)
      Description copied from interface: Sequencer
      Add the specified gating sequences to this instance of the Disruptor. They will safely and atomically added to the list of gating sequences.
      Specified by:
      addGatingSequences in interface Sequencer
      Parameters:
      gatingSequences - The sequences to add.
      See Also:
    • removeGatingSequence

      public boolean removeGatingSequence(Sequence sequence)
      Description copied from interface: Sequencer
      Remove the specified sequence from this sequencer.
      Specified by:
      removeGatingSequence in interface Sequencer
      Parameters:
      sequence - to be removed.
      Returns:
      true if this sequence was found, false otherwise.
      See Also:
    • getMinimumSequence

      public long getMinimumSequence()
      Description copied from interface: Sequencer
      Get the minimum sequence value from all of the gating sequences added to this ringBuffer.
      Specified by:
      getMinimumSequence in interface Sequencer
      Returns:
      The minimum gating sequence or the cursor sequence if no sequences have been added.
      See Also:
    • newBarrier

      public SequenceBarrier newBarrier(Sequence... sequencesToTrack)
      Description copied from interface: Sequencer
      Create a new SequenceBarrier to be used by an EventProcessor to track which messages are available to be read from the ring buffer given a list of sequences to track.
      Specified by:
      newBarrier in interface Sequencer
      Parameters:
      sequencesToTrack - All of the sequences that the newly constructed barrier will wait on.
      Returns:
      A sequence barrier that will track the specified sequences.
      See Also:
    • newPoller

      public <T> EventPoller<T> newPoller(DataProvider<T> dataProvider, Sequence... gatingSequences)
      Creates an event poller for this sequence that will use the supplied data provider and gating sequences.
      Specified by:
      newPoller in interface Sequencer
      Parameters:
      dataProvider - The data source for users of this event poller
      gatingSequences - Sequence to be gated on.
      Returns:
      A poller that will gate on this ring buffer and the supplied sequences.
    • toString

      public String toString()
      Overrides:
      toString in class Object