com.lmax.disruptor
Class RingBuffer<T extends AbstractEntry>

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

public final class RingBuffer<T extends AbstractEntry>
extends java.lang.Object

Ring based store of reusable entries containing the data representing an AbstractEntry being exchanged between producers and consumers.


Field Summary
static long INITIAL_CURSOR_VALUE
          Set to -1 as sequence starting point
 long p1
           
 long p10
           
 long p11
           
 long p12
           
 long p13
           
 long p14
           
 long p2
           
 long p3
           
 long p4
           
 long p5
           
 long p6
           
 long p7
           
 long p8
           
 long p9
           
 
Constructor Summary
RingBuffer(EntryFactory<T> entryFactory, int size)
          Construct a RingBuffer with default strategies of: ClaimStrategy.Option.MULTI_THREADED and WaitStrategy.Option.BLOCKING
RingBuffer(EntryFactory<T> entryFactory, int size, ClaimStrategy.Option claimStrategyOption, WaitStrategy.Option waitStrategyOption)
          Construct a RingBuffer with the full option set.
 
Method Summary
 ConsumerBarrier<T> createConsumerBarrier(Consumer... consumersToTrack)
          Create a ConsumerBarrier that gates on the RingBuffer and a list of Consumers
 ForceFillProducerBarrier<T> createForceFillProducerBarrier(Consumer... consumersToTrack)
          Create a ForceFillProducerBarrier on this RingBuffer that tracks dependent Consumers.
 ProducerBarrier<T> createProducerBarrier(Consumer... consumersToTrack)
          Create a ProducerBarrier on this RingBuffer that tracks dependent Consumers.
 int getCapacity()
          The capacity of the RingBuffer to hold entries.
 long getCursor()
          Get the current sequence that producers have committed to the RingBuffer.
 T getEntry(long sequence)
          Get the AbstractEntry for a given sequence in the RingBuffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CURSOR_VALUE

public static final long INITIAL_CURSOR_VALUE
Set to -1 as sequence starting point

See Also:
Constant Field Values

p1

public long p1

p2

public long p2

p3

public long p3

p4

public long p4

p5

public long p5

p6

public long p6

p7

public long p7

p8

public long p8

p9

public long p9

p10

public long p10

p11

public long p11

p12

public long p12

p13

public long p13

p14

public long p14
Constructor Detail

RingBuffer

public RingBuffer(EntryFactory<T> entryFactory,
                  int size,
                  ClaimStrategy.Option claimStrategyOption,
                  WaitStrategy.Option waitStrategyOption)
Construct a RingBuffer with the full option set.

Parameters:
entryFactory - to create AbstractEntrys for filling the RingBuffer
size - of the RingBuffer that will be rounded up to the next power of 2
claimStrategyOption - threading strategy for producers claiming AbstractEntrys in the ring.
waitStrategyOption - waiting strategy employed by consumers waiting on AbstractEntrys becoming available.

RingBuffer

public RingBuffer(EntryFactory<T> entryFactory,
                  int size)
Construct a RingBuffer with default strategies of: ClaimStrategy.Option.MULTI_THREADED and WaitStrategy.Option.BLOCKING

Parameters:
entryFactory - to create AbstractEntrys for filling the RingBuffer
size - of the RingBuffer that will be rounded up to the next power of 2
Method Detail

createConsumerBarrier

public ConsumerBarrier<T> createConsumerBarrier(Consumer... consumersToTrack)
Create a ConsumerBarrier that gates on the RingBuffer and a list of Consumers

Parameters:
consumersToTrack - this barrier will track
Returns:
the barrier gated as required

createProducerBarrier

public ProducerBarrier<T> createProducerBarrier(Consumer... consumersToTrack)
Create a ProducerBarrier on this RingBuffer that tracks dependent Consumers.

Parameters:
consumersToTrack - to be tracked to prevent wrapping.
Returns:
a ProducerBarrier with the above configuration.

createForceFillProducerBarrier

public ForceFillProducerBarrier<T> createForceFillProducerBarrier(Consumer... consumersToTrack)
Create a ForceFillProducerBarrier on this RingBuffer that tracks dependent Consumers. This barrier is to be used for filling a RingBuffer when no other producers exist.

Parameters:
consumersToTrack - to be tracked to prevent wrapping.
Returns:
a ForceFillProducerBarrier with the above configuration.

getCapacity

public int getCapacity()
The capacity of the RingBuffer to hold entries.

Returns:
the size of the RingBuffer.

getCursor

public long getCursor()
Get the current sequence that producers have committed to the RingBuffer.

Returns:
the current committed sequence.

getEntry

public T getEntry(long sequence)
Get the AbstractEntry for a given sequence in the RingBuffer.

Parameters:
sequence - for the AbstractEntry
Returns:
AbstractEntry for the sequence


Copyright © 2011 LMAX Ltd. All Rights Reserved.