com.pmease.quickbuild.util
Class RingBuffer<T>

java.lang.Object
  extended by com.pmease.quickbuild.util.RingBuffer<T>
Type Parameters:
T -

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

Modeled after Imax disruptor ringbuffer (see http://lmax-exchange.github.com/disruptor/), but this is a simple clone, and it is not thread-safe.


Nested Class Summary
static interface RingBuffer.EventFactory<T>
           
 
Field Summary
protected  java.util.concurrent.atomic.AtomicLong sequence
           
 
Constructor Summary
RingBuffer(RingBuffer.EventFactory<T> factory, int bufferSize)
           
 
Method Summary
 T get(long seq)
           
 long getCursor()
           
 T getLast()
           
 java.util.List<T> getLastN(int n)
           
 long next()
           
 void publish(long sequence)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sequence

protected java.util.concurrent.atomic.AtomicLong sequence
Constructor Detail

RingBuffer

public RingBuffer(RingBuffer.EventFactory<T> factory,
                  int bufferSize)
Method Detail

get

public T get(long seq)

getCursor

public long getCursor()

getLastN

public java.util.List<T> getLastN(int n)

getLast

public T getLast()

publish

public void publish(long sequence)

next

public long next()


Copyright © 2005-2010 PMEase Inc. All Rights Reserved.