com.lmax.disruptor
Class MultiThreadedClaimStrategy

java.lang.Object
  extended by com.lmax.disruptor.AbstractMultithreadedClaimStrategy
      extended by com.lmax.disruptor.MultiThreadedClaimStrategy
All Implemented Interfaces:
ClaimStrategy

public final class MultiThreadedClaimStrategy
extends AbstractMultithreadedClaimStrategy
implements ClaimStrategy

Strategy to be used when there are multiple publisher threads claiming sequences. This strategy is reasonably forgiving when the multiple publisher threads are highly contended or working in an environment where there is insufficient CPUs to handle multiple publisher threads. It requires 2 CAS operations for a single publisher, compared to the MultiThreadedLowContentionClaimStrategy strategy which needs only a single CAS and a lazySet per publication.


Constructor Summary
MultiThreadedClaimStrategy(int bufferSize)
          Construct a new multi-threaded publisher ClaimStrategy for a given buffer size.
MultiThreadedClaimStrategy(int bufferSize, int pendingBufferSize)
          Construct a new multi-threaded publisher ClaimStrategy for a given buffer size.
 
Method Summary
 void serialisePublishing(long sequence, Sequence cursor, int batchSize)
          Serialise publishers in sequence and set cursor to latest available sequence.
 
Methods inherited from class com.lmax.disruptor.AbstractMultithreadedClaimStrategy
checkAndIncrement, getBufferSize, getSequence, hasAvailableCapacity, incrementAndGet, incrementAndGet, setSequence
 
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
checkAndIncrement, getBufferSize, getSequence, hasAvailableCapacity, incrementAndGet, incrementAndGet, setSequence
 

Constructor Detail

MultiThreadedClaimStrategy

public MultiThreadedClaimStrategy(int bufferSize,
                                  int pendingBufferSize)
Construct a new multi-threaded publisher ClaimStrategy for a given buffer size.

Parameters:
bufferSize - for the underlying data structure.
pendingBufferSize - number of item that can be pending for serialisation

MultiThreadedClaimStrategy

public MultiThreadedClaimStrategy(int bufferSize)
Construct a new multi-threaded publisher ClaimStrategy for a given buffer size.

Parameters:
bufferSize - for the underlying data structure.
Method Detail

serialisePublishing

public void serialisePublishing(long sequence,
                                Sequence cursor,
                                int batchSize)
Description copied from interface: ClaimStrategy
Serialise publishers in sequence and set cursor to latest available sequence.

Specified by:
serialisePublishing in interface ClaimStrategy
Parameters:
sequence - sequence to be applied
cursor - to serialise against.
batchSize - of the sequence.


Copyright © 2011 LMAX Ltd. All Rights Reserved.