com.lmax.disruptor
Class RingBuffer<T>

java.lang.Object
  extended by com.lmax.disruptor.Sequencer
      extended by com.lmax.disruptor.RingBuffer<T>
Type Parameters:
T - implementation storing the data for sharing during exchange or parallel coordination of an event.

public final class RingBuffer<T>
extends Sequencer

Ring based store of reusable entries containing the data representing an event being exchanged between event publisher and EventProcessors.


Field Summary
 
Fields inherited from class com.lmax.disruptor.Sequencer
INITIAL_CURSOR_VALUE
 
Constructor Summary
RingBuffer(EventFactory<T> eventFactory, ClaimStrategy claimStrategy, WaitStrategy waitStrategy)
          Construct a RingBuffer with the full option set.
RingBuffer(EventFactory<T> eventFactory, int bufferSize)
          Construct a RingBuffer with default strategies of: MultiThreadedClaimStrategy and BlockingWaitStrategy
 
Method Summary
 T get(long sequence)
          Get the event for a given sequence in the RingBuffer.
 
Methods inherited from class com.lmax.disruptor.Sequencer
claim, forcePublish, getBufferSize, getCursor, hasAvailableCapacity, newBarrier, newBatchDescriptor, next, next, publish, publish, remainingCapacity, setGatingSequences, tryNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RingBuffer

public RingBuffer(EventFactory<T> eventFactory,
                  ClaimStrategy claimStrategy,
                  WaitStrategy waitStrategy)
Construct a RingBuffer with the full option set.

Parameters:
eventFactory - to newInstance entries for filling the RingBuffer
claimStrategy - threading strategy for publisher claiming entries in the ring.
waitStrategy - waiting strategy employed by processorsToTrack waiting on entries becoming available.
Throws:
java.lang.IllegalArgumentException - if bufferSize is not a power of 2

RingBuffer

public RingBuffer(EventFactory<T> eventFactory,
                  int bufferSize)
Construct a RingBuffer with default strategies of: MultiThreadedClaimStrategy and BlockingWaitStrategy

Parameters:
eventFactory - to newInstance entries for filling the RingBuffer
bufferSize - of the RingBuffer that will be rounded up to the next power of 2
Method Detail

get

public T get(long sequence)
Get the event for a given sequence in the RingBuffer.

Parameters:
sequence - for the event
Returns:
event for the sequence


Copyright © 2011 LMAX Ltd. All Rights Reserved.