public final class MultiProducerSequencer extends AbstractSequencer
Sequence
s
Suitable for use for sequencing across multiple publisher threads.bufferSize, cursor, gatingSequences, waitStrategy
INITIAL_CURSOR_VALUE
Constructor and Description |
---|
MultiProducerSequencer(int bufferSize,
WaitStrategy waitStrategy)
Construct a Sequencer with the selected wait strategy and buffer size.
|
Modifier and Type | Method and Description |
---|---|
void |
claim(long sequence)
Claim a specific sequence.
|
long |
getHighestPublishedSequence(long lowerBound,
long availableSequence) |
boolean |
hasAvailableCapacity(int requiredCapacity)
Has the buffer got capacity to allocate another sequence.
|
boolean |
isAvailable(long sequence)
Confirms if a sequence is published and the event is available for use; non-blocking.
|
long |
next()
Claim the next event in sequence for publishing.
|
long |
next(int n)
Claim the next n events in sequence for publishing.
|
void |
publish(long sequence)
Publishes a sequence.
|
void |
publish(long lo,
long hi)
Batch publish sequences.
|
long |
remainingCapacity()
Get the remaining capacity for this sequencer.
|
long |
tryNext()
Attempt to claim the next event in sequence for publishing.
|
long |
tryNext(int n)
Attempt to claim the next n events in sequence for publishing.
|
addGatingSequences, getBufferSize, getCursor, getMinimumSequence, newBarrier, removeGatingSequence
public MultiProducerSequencer(int bufferSize, WaitStrategy waitStrategy)
bufferSize
- the size of the buffer that this will sequence over.waitStrategy
- for those waiting on sequences.public boolean hasAvailableCapacity(int requiredCapacity)
Sequencer
requiredCapacity
- in the bufferSequencer.hasAvailableCapacity(int)
public void claim(long sequence)
Sequencer
sequence
- The sequence to initialise too.Sequencer.claim(long)
public long next()
Sequencer
Sequencer.next()
public long next(int n)
Sequencer
int n = 10; long hi = sequencer.next(n); long lo = hi - (n - 1); for (long sequence = lo; sequence <= hi; sequence++) { // Do work. } sequencer.publish(lo, hi);
n
- the number of sequences to claimSequencer.next(int)
public long tryNext() throws InsufficientCapacityException
Sequencer
requiredCapacity
slots
available.InsufficientCapacityException
Sequencer.tryNext()
public long tryNext(int n) throws InsufficientCapacityException
Sequencer
requiredCapacity
slots
available. Have a look at Sequencer.next()
for a description on how to
use this method.n
- the number of sequences to claimInsufficientCapacityException
Sequencer.tryNext(int)
public long remainingCapacity()
Sequencer
Sequencer.remainingCapacity()
public void publish(long sequence)
Sequencer
Sequencer.publish(long)
public void publish(long lo, long hi)
Sequencer
lo
- first sequence number to publishhi
- last sequence number to publishSequencer.publish(long, long)
public boolean isAvailable(long sequence)
Sequencer
sequence
- of the buffer to checkSequencer.isAvailable(long)
public long getHighestPublishedSequence(long lowerBound, long availableSequence)
Copyright © 2014. All rights reserved.