com.timeindexing.util
Class ByteBufferRing

java.lang.Object
  extended bycom.timeindexing.util.ByteBufferRing

public class ByteBufferRing
extends java.lang.Object

A ring of ByteBuffers. There will be a 'current' buffer in the ring. A buffer can be locked, so it can;t be used again. A buffer can be freed, so it can be used again.


Constructor Summary
ByteBufferRing(int count, int bufSize)
          Construct a ByteBufferRing with N ByteBuffers.
 
Method Summary
 java.nio.ByteBuffer current()
          Get the current buffer.
 int free()
          How many free buffers are there.
 int getBufferSize()
          Get the size of the buffers in the ring.
 int grow(int growSize)
          Grow the ring by N new buffers.
 int lock()
          Lock the current buffer.
 int size()
          Get the size of the ring.
 java.lang.String toString()
          String
 int unlock(java.nio.ByteBuffer buffer)
          Unlock a buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteBufferRing

public ByteBufferRing(int count,
                      int bufSize)
Construct a ByteBufferRing with N ByteBuffers.

Method Detail

size

public int size()
Get the size of the ring.


getBufferSize

public int getBufferSize()
Get the size of the buffers in the ring.


current

public java.nio.ByteBuffer current()
Get the current buffer.


free

public int free()
How many free buffers are there.


lock

public int lock()
Lock the current buffer. Returns the no of free buffers.


unlock

public int unlock(java.nio.ByteBuffer buffer)
Unlock a buffer. Returns the no of free buffers.


grow

public int grow(int growSize)
Grow the ring by N new buffers.


toString

public java.lang.String toString()
String