org.szegedi.nbpipe
Class GlobalByteBufferPool

java.lang.Object
  |
  +--org.szegedi.nbpipe.GlobalByteBufferPool
All Implemented Interfaces:
ByteBufferPool

public class GlobalByteBufferPool
extends java.lang.Object
implements ByteBufferPool


Field Summary
 
Fields inherited from interface org.szegedi.nbpipe.ByteBufferPool
TYPE_FILE, TYPE_MEMORY, TYPE_UNKNOWN
 
Constructor Summary
GlobalByteBufferPool(int memorySize, int fileSize, java.io.File file)
           
 
Method Summary
 int getBufferType(java.nio.ByteBuffer buffer)
           
 java.nio.ByteBuffer getFileBuffer()
          Returns a buffer from this pool.
 java.nio.ByteBuffer getMemoryBuffer()
          Returns a buffer from this pool.
 boolean isBlockingWhenExhausted()
           
 void putBuffer(java.nio.ByteBuffer buffer)
          Returns a buffer to this pool.
 void setBlockingWhenExhausted(boolean blocking)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalByteBufferPool

public GlobalByteBufferPool(int memorySize,
                            int fileSize,
                            java.io.File file)
                     throws java.io.IOException
Method Detail

setBlockingWhenExhausted

public void setBlockingWhenExhausted(boolean blocking)

isBlockingWhenExhausted

public boolean isBlockingWhenExhausted()

getMemoryBuffer

public java.nio.ByteBuffer getMemoryBuffer()
Description copied from interface: ByteBufferPool
Returns a buffer from this pool. The method first attempts to return a memory buffer. If one is not available, it attempts to return a file buffer. If neither a file buffer is available, it will (depending on whether the pool blocks when exhausted) block while a memory buffer becomes available, or allocate a new, non-direct, one-shot memory buffer from the heap.

Specified by:
getMemoryBuffer in interface ByteBufferPool

getFileBuffer

public java.nio.ByteBuffer getFileBuffer()
Description copied from interface: ByteBufferPool
Returns a buffer from this pool. The method first attempts to return a file buffer. If one is not available, it attempts to return a memory buffer. If neither a memory buffer is available, it will (depending on whether the pool blocks when exhausted) block while a file buffer becomes available, or allocate a new, non-direct, one-shot memory buffer from the heap.

Specified by:
getFileBuffer in interface ByteBufferPool

putBuffer

public void putBuffer(java.nio.ByteBuffer buffer)
Description copied from interface: ByteBufferPool
Returns a buffer to this pool. If the buffer is a non-direct buffer, it should be ignored. If the buffer is a direct buffer, but is recognized as not belonging to this pool, an IllegalArgumentException should be thrown.

Specified by:
putBuffer in interface ByteBufferPool

getBufferType

public int getBufferType(java.nio.ByteBuffer buffer)
Specified by:
getBufferType in interface ByteBufferPool