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 int
protected final Sequence
protected Sequence[]
private static final AtomicReferenceFieldUpdater
<AbstractSequencer, Sequence[]> protected final WaitStrategy
Fields 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 void
addGatingSequences
(Sequence... gatingSequences) Add the specified gating sequences to this instance of the Disruptor.final int
The capacity of the data structure to hold entries.final long
Get the current cursor value.long
Get 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.boolean
removeGatingSequence
(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, wait
Methods inherited from interface com.lmax.disruptor.Sequenced
hasAvailableCapacity, next, next, publish, publish, remainingCapacity, tryNext, tryNext
Methods 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:Cursored
Get the current cursor value. -
getBufferSize
public final int getBufferSize()Description copied from interface:Sequenced
The capacity of the data structure to hold entries.- Specified by:
getBufferSize
in interfaceSequenced
- Returns:
- the size of the RingBuffer.
- See Also:
-
addGatingSequences
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 interfaceSequencer
- Parameters:
gatingSequences
- The sequences to add.- See Also:
-
removeGatingSequence
Description copied from interface:Sequencer
Remove the specified sequence from this sequencer.- Specified by:
removeGatingSequence
in 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:Sequencer
Get the minimum sequence value from all of the gating sequences added to this ringBuffer.- Specified by:
getMinimumSequence
in interfaceSequencer
- Returns:
- The minimum gating sequence or the cursor sequence if no sequences have been added.
- See Also:
-
newBarrier
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 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
-