|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lmax.disruptor.SingleThreadedClaimStrategy
public final class SingleThreadedClaimStrategy
Optimised strategy can be used when there is a single publisher thread claiming sequences.
This strategy must not be used when multiple threads are used for publishing concurrently on the same Sequencer
| Constructor Summary | |
|---|---|
SingleThreadedClaimStrategy(int bufferSize)
Construct a new single threaded publisher ClaimStrategy for a given buffer size. |
|
| Method Summary | |
|---|---|
long |
checkAndIncrement(int availableCapacity,
int delta,
Sequence[] dependentSequences)
Atomically checks the available capacity of the ring buffer and claims the next sequence. |
int |
getBufferSize()
Get the size of the data structure used to buffer events. |
long |
getSequence()
Get the current claimed sequence. |
boolean |
hasAvailableCapacity(int availableCapacity,
Sequence[] dependentSequences)
Is there available capacity in the buffer for the requested sequence. |
long |
incrementAndGet(int delta,
Sequence[] dependentSequences)
Increment sequence by a delta and get the result. |
long |
incrementAndGet(Sequence[] dependentSequences)
Claim the next sequence in the Sequencer. |
void |
serialisePublishing(long sequence,
Sequence cursor,
int batchSize)
Serialise publishers in sequence and set cursor to latest available sequence. |
void |
setSequence(long sequence,
Sequence[] dependentSequences)
Set the current sequence value for claiming an event in the Sequencer
The caller should be held up until the claimed sequence is available by tracking the dependentSequences. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SingleThreadedClaimStrategy(int bufferSize)
ClaimStrategy for a given buffer size.
bufferSize - for the underlying data structure.| Method Detail |
|---|
public int getBufferSize()
ClaimStrategy
getBufferSize in interface ClaimStrategypublic long getSequence()
ClaimStrategy
getSequence in interface ClaimStrategy
public boolean hasAvailableCapacity(int availableCapacity,
Sequence[] dependentSequences)
ClaimStrategy
hasAvailableCapacity in interface ClaimStrategyavailableCapacity - remaining in the buffer.dependentSequences - to be checked for range.
public long incrementAndGet(Sequence[] dependentSequences)
ClaimStrategySequencer.
The caller should be held up until the claimed sequence is available by tracking the dependentSequences.
incrementAndGet in interface ClaimStrategydependentSequences - to be checked for range.
public long incrementAndGet(int delta,
Sequence[] dependentSequences)
ClaimStrategy
incrementAndGet in interface ClaimStrategydelta - to increment by.dependentSequences - to be checked for range.
public void setSequence(long sequence,
Sequence[] dependentSequences)
ClaimStrategySequencer
The caller should be held up until the claimed sequence is available by tracking the dependentSequences.
setSequence in interface ClaimStrategysequence - to be set as the current value.dependentSequences - to be checked for range.
public void serialisePublishing(long sequence,
Sequence cursor,
int batchSize)
ClaimStrategy
serialisePublishing in interface ClaimStrategysequence - sequence to be appliedcursor - to serialise against.batchSize - of the sequence.
public long checkAndIncrement(int availableCapacity,
int delta,
Sequence[] dependentSequences)
throws InsufficientCapacityException
ClaimStrategy
checkAndIncrement in interface ClaimStrategyavailableCapacity - the capacity that should be available before claiming the next slotdelta - the number of slots to claimdependentSequences - the set of sequences to check to ensure capacity is available
InsufficientCapacityException - thrown if capacity is not available
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||