com.lmax.disruptor
Class AbstractMultithreadedClaimStrategy

java.lang.Object
  extended by com.lmax.disruptor.AbstractMultithreadedClaimStrategy
All Implemented Interfaces:
ClaimStrategy
Direct Known Subclasses:
MultiThreadedClaimStrategy, MultiThreadedLowContentionClaimStrategy

public abstract class AbstractMultithreadedClaimStrategy
extends java.lang.Object
implements ClaimStrategy


Constructor Summary
AbstractMultithreadedClaimStrategy(int bufferSize)
           
 
Method Summary
 long checkAndIncrement(int availableCapacity, int delta, Sequence[] gatingSequences)
          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 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
 
Methods inherited from interface com.lmax.disruptor.ClaimStrategy
serialisePublishing
 

Constructor Detail

AbstractMultithreadedClaimStrategy

public AbstractMultithreadedClaimStrategy(int bufferSize)
Method Detail

getBufferSize

public int getBufferSize()
Description copied from interface: ClaimStrategy
Get the size of the data structure used to buffer events.

Specified by:
getBufferSize in interface ClaimStrategy
Returns:
size of the underlying buffer.

getSequence

public long getSequence()
Description copied from interface: ClaimStrategy
Get the current claimed sequence.

Specified by:
getSequence in interface ClaimStrategy
Returns:
the current claimed sequence.

hasAvailableCapacity

public boolean hasAvailableCapacity(int availableCapacity,
                                    Sequence[] dependentSequences)
Description copied from interface: ClaimStrategy
Is there available capacity in the buffer for the requested sequence.

Specified by:
hasAvailableCapacity in interface ClaimStrategy
Parameters:
availableCapacity - remaining in the buffer.
dependentSequences - to be checked for range.
Returns:
true if the buffer has capacity for the requested sequence.

incrementAndGet

public long incrementAndGet(Sequence[] dependentSequences)
Description copied from interface: ClaimStrategy
Claim the next sequence in the Sequencer. The caller should be held up until the claimed sequence is available by tracking the dependentSequences.

Specified by:
incrementAndGet in interface ClaimStrategy
Parameters:
dependentSequences - to be checked for range.
Returns:
the index to be used for the publishing.

checkAndIncrement

public long checkAndIncrement(int availableCapacity,
                              int delta,
                              Sequence[] gatingSequences)
                       throws InsufficientCapacityException
Description copied from interface: ClaimStrategy
Atomically checks the available capacity of the ring buffer and claims the next sequence. Will throw InsufficientCapacityException if the capacity not available.

Specified by:
checkAndIncrement in interface ClaimStrategy
Parameters:
availableCapacity - the capacity that should be available before claiming the next slot
delta - the number of slots to claim
gatingSequences - the set of sequences to check to ensure capacity is available
Returns:
the slot after incrementing
Throws:
InsufficientCapacityException - thrown if capacity is not available

incrementAndGet

public long incrementAndGet(int delta,
                            Sequence[] dependentSequences)
Description copied from interface: ClaimStrategy
Increment sequence by a delta and get the result. The caller should be held up until the claimed sequence batch is available by tracking the dependentSequences.

Specified by:
incrementAndGet in interface ClaimStrategy
Parameters:
delta - to increment by.
dependentSequences - to be checked for range.
Returns:
the result after incrementing.

setSequence

public void setSequence(long sequence,
                        Sequence[] dependentSequences)
Description copied from interface: ClaimStrategy
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.

Specified by:
setSequence in interface ClaimStrategy
Parameters:
sequence - to be set as the current value.
dependentSequences - to be checked for range.


Copyright © 2011 LMAX Ltd. All Rights Reserved.