Package com.lmax.disruptor
Class AbstractSequencer
java.lang.Object
com.lmax.disruptor.AbstractSequencer
- Direct Known Subclasses:
MultiProducerSequencer,SingleProducerSequencerPad
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 Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final Sequenceprotected Sequence[]private static final AtomicReferenceFieldUpdater<AbstractSequencer, Sequence[]> protected final WaitStrategyFields inherited from interface com.lmax.disruptor.Sequencer
INITIAL_CURSOR_VALUE -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSequencer(int bufferSize, WaitStrategy waitStrategy) Create with the specified buffer size and wait strategy. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddGatingSequences(Sequence... gatingSequences) Add the specified gating sequences to this instance of the Disruptor.final intThe capacity of the data structure to hold entries.final longGet the current cursor value.longGet the minimum sequence value from all of the gating sequences added to this ringBuffer.newBarrier(Sequence... sequencesToTrack) 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.<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.booleanremoveGatingSequence(Sequence sequence) Remove the specified sequence from this sequencer.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.lmax.disruptor.Sequenced
hasAvailableCapacity, next, next, publish, publish, remainingCapacity, tryNext, tryNextMethods inherited from interface com.lmax.disruptor.Sequencer
claim, getHighestPublishedSequence, isAvailable
-
Field Details
-
SEQUENCE_UPDATER
-
bufferSize
protected final int bufferSize -
waitStrategy
-
cursor
-
gatingSequences
-
-
Constructor Details
-
AbstractSequencer
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:CursoredGet the current cursor value. -
getBufferSize
public final int getBufferSize()Description copied from interface:SequencedThe capacity of the data structure to hold entries.- Specified by:
getBufferSizein interfaceSequenced- Returns:
- the size of the RingBuffer.
- See Also:
-
addGatingSequences
Description copied from interface:SequencerAdd the specified gating sequences to this instance of the Disruptor. They will safely and atomically added to the list of gating sequences.- Specified by:
addGatingSequencesin interfaceSequencer- Parameters:
gatingSequences- The sequences to add.- See Also:
-
removeGatingSequence
Description copied from interface:SequencerRemove the specified sequence from this sequencer.- Specified by:
removeGatingSequencein interfaceSequencer- Parameters:
sequence- to be removed.- Returns:
- true if this sequence was found, false otherwise.
- See Also:
-
getMinimumSequence
public long getMinimumSequence()Description copied from interface:SequencerGet the minimum sequence value from all of the gating sequences added to this ringBuffer.- Specified by:
getMinimumSequencein interfaceSequencer- Returns:
- The minimum gating sequence or the cursor sequence if no sequences have been added.
- See Also:
-
newBarrier
Description copied from interface:SequencerCreate 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:
newBarrierin interfaceSequencer- 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
Creates an event poller for this sequence that will use the supplied data provider and gating sequences. -
toString
-