- java.lang.Object
-
- com.lmax.disruptor.AbstractSequencer
-
- Direct Known Subclasses:
MultiProducerSequencer
,SingleProducerSequencer
public abstract class AbstractSequencer extends java.lang.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 Summary
-
Fields inherited from interface com.lmax.disruptor.Sequencer
INITIAL_CURSOR_VALUE
-
-
Constructor Summary
Constructors Constructor Description AbstractSequencer(int bufferSize, WaitStrategy waitStrategy)
Create with the specified buffer size and wait strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addGatingSequences(Sequence... gatingSequences)
Add the specified gating sequences to this instance of the Disruptor.int
getBufferSize()
The capacity of the data structure to hold entries.long
getCursor()
Get the current cursor value.long
getMinimumSequence()
Get the minimum sequence value from all of the gating sequences added to this ringBuffer.SequenceBarrier
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.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
equals, 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
-
-
-
-
Constructor Detail
-
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 Detail
-
getCursor
public final long getCursor()
Description copied from interface:Cursored
Get the current cursor value.- Specified by:
getCursor
in interfaceCursored
- Returns:
- current cursor value
- See Also:
Cursored.getCursor()
-
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:
Sequenced.getBufferSize()
-
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 interfaceSequencer
- Parameters:
gatingSequences
- The sequences to add.- See Also:
Sequencer.addGatingSequences(Sequence...)
-
removeGatingSequence
public boolean removeGatingSequence(Sequence sequence)
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:
Sequencer.removeGatingSequence(Sequence)
-
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:
Sequencer.getMinimumSequence()
-
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 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:
Sequencer.newBarrier(Sequence...)
-
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.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-