@InterfaceAudience.Private public class ByteBufferPool extends Object
Note: This pool returns off heap ByteBuffers by default. If on heap ByteBuffers to be pooled, pass 'directByteBuffer' as false while construction of the pool.
This class is thread safe.
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
BUFFER_SIZE_KEY |
static int |
DEFAULT_BUFFER_SIZE |
static String |
MAX_POOL_SIZE_KEY |
| 构造器和说明 |
|---|
ByteBufferPool(int bufferSize,
int maxPoolSize) |
ByteBufferPool(int bufferSize,
int maxPoolSize,
boolean directByteBuffer) |
| 限定符和类型 | 方法和说明 |
|---|---|
ByteBuffer |
getBuffer() |
int |
getBufferSize() |
int |
getQueueSize() |
void |
putbackBuffer(ByteBuffer buf)
Return back a ByteBuffer after its use.
|
public static final int DEFAULT_BUFFER_SIZE
public ByteBufferPool(int bufferSize,
int maxPoolSize)
bufferSize - Size of each buffer created by this pool.maxPoolSize - Max number of buffers to keep in this pool.public ByteBufferPool(int bufferSize,
int maxPoolSize,
boolean directByteBuffer)
bufferSize - Size of each buffer created by this pool.maxPoolSize - Max number of buffers to keep in this pool.directByteBuffer - Whether to create direct ByteBuffer or on heap ByteBuffer.public ByteBuffer getBuffer()
putbackBuffer(ByteBuffer)public void putbackBuffer(ByteBuffer buf)
buf - ByteBuffer to return.public int getBufferSize()
public int getQueueSize()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.