public class ArrayByteBufferPool extends java.lang.Object implements ByteBufferPool
ByteBufferPool.Bucket, ByteBufferPool.Lease| Modifier and Type | Field and Description |
|---|---|
private ByteBufferPool.Bucket[] |
_direct |
private int |
_inc |
private ByteBufferPool.Bucket[] |
_indirect |
private int |
_maxQueue |
private int |
_min |
| Constructor and Description |
|---|
ArrayByteBufferPool() |
ArrayByteBufferPool(int minSize,
int increment,
int maxSize) |
ArrayByteBufferPool(int minSize,
int increment,
int maxSize,
int maxQueue) |
| Modifier and Type | Method and Description |
|---|---|
java.nio.ByteBuffer |
acquire(int size,
boolean direct)
Requests a
ByteBuffer of the given size. |
private ByteBufferPool.Bucket |
bucketFor(int size,
boolean direct) |
(package private) ByteBufferPool.Bucket[] |
bucketsFor(boolean direct) |
void |
clear() |
void |
release(java.nio.ByteBuffer buffer)
Returns a
ByteBuffer, usually obtained with ByteBufferPool.acquire(int, boolean)
(but not necessarily), making it available for recycling and reuse. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewByteBufferprivate final int _min
private final int _maxQueue
private final ByteBufferPool.Bucket[] _direct
private final ByteBufferPool.Bucket[] _indirect
private final int _inc
public ArrayByteBufferPool()
public ArrayByteBufferPool(int minSize,
int increment,
int maxSize)
public ArrayByteBufferPool(int minSize,
int increment,
int maxSize,
int maxQueue)
public java.nio.ByteBuffer acquire(int size,
boolean direct)
ByteBufferPoolRequests a ByteBuffer of the given size.
The returned buffer may have a bigger capacity than the size being requested but it will have the limit set to the given size.
acquire in interface ByteBufferPoolsize - the size of the bufferdirect - whether the buffer must be direct or notByteBufferPool.release(ByteBuffer)public void release(java.nio.ByteBuffer buffer)
ByteBufferPoolReturns a ByteBuffer, usually obtained with ByteBufferPool.acquire(int, boolean)
(but not necessarily), making it available for recycling and reuse.
release in interface ByteBufferPoolbuffer - the buffer to returnByteBufferPool.acquire(int, boolean)public void clear()
private ByteBufferPool.Bucket bucketFor(int size, boolean direct)
ByteBufferPool.Bucket[] bucketsFor(boolean direct)