Package com.lmax.disruptor
Interface Sequencer
- All Known Implementing Classes:
AbstractSequencer
,MultiProducerSequencer
,SingleProducerSequencer
,SingleProducerSequencerFields
,SingleProducerSequencerPad
Coordinates claiming sequences for access to a data structure while tracking dependent
Sequence
s-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final long
Set to -1 as sequence starting point -
Method Summary
Modifier and TypeMethodDescriptionvoid
addGatingSequences
(Sequence... gatingSequences) Add the specified gating sequences to this instance of the Disruptor.void
claim
(long sequence) Claim a specific sequence.long
getHighestPublishedSequence
(long nextSequence, long availableSequence) Get the highest sequence number that can be safely read from the ring buffer.long
Get the minimum sequence value from all of the gating sequences added to this ringBuffer.boolean
isAvailable
(long sequence) Confirms if a sequence is published and the event is available for use; non-blocking.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> provider, Sequence... gatingSequences) boolean
removeGatingSequence
(Sequence sequence) Remove the specified sequence from this sequencer.Methods inherited from interface com.lmax.disruptor.Sequenced
getBufferSize, hasAvailableCapacity, next, next, publish, publish, remainingCapacity, tryNext, tryNext
-
Field Details
-
INITIAL_CURSOR_VALUE
static final long INITIAL_CURSOR_VALUESet to -1 as sequence starting point- See Also:
-
-
Method Details
-
claim
void claim(long sequence) Claim a specific sequence. Only used if initialising the ring buffer to a specific value.- Parameters:
sequence
- The sequence to initialise too.
-
isAvailable
boolean isAvailable(long sequence) Confirms if a sequence is published and the event is available for use; non-blocking.- Parameters:
sequence
- of the buffer to check- Returns:
- true if the sequence is available for use, false if not
-
addGatingSequences
Add the specified gating sequences to this instance of the Disruptor. They will safely and atomically added to the list of gating sequences.- Parameters:
gatingSequences
- The sequences to add.
-
removeGatingSequence
Remove the specified sequence from this sequencer.- Parameters:
sequence
- to be removed.- Returns:
- true if this sequence was found, false otherwise.
-
newBarrier
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.- 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:
-
getMinimumSequence
long getMinimumSequence()Get the minimum sequence value from all of the gating sequences added to this ringBuffer.- Returns:
- The minimum gating sequence or the cursor sequence if no sequences have been added.
-
getHighestPublishedSequence
long getHighestPublishedSequence(long nextSequence, long availableSequence) Get the highest sequence number that can be safely read from the ring buffer. Depending on the implementation of the Sequencer this call may need to scan a number of values in the Sequencer. The scan will range from nextSequence to availableSequence. If there are no available values>= nextSequence
the return value will benextSequence - 1
. To work correctly a consumer should pass a value that is 1 higher than the last sequence that was successfully processed.- Parameters:
nextSequence
- The sequence to start scanning from.availableSequence
- The sequence to scan to.- Returns:
- The highest value that can be safely read, will be at least
nextSequence - 1
.
-
newPoller
-