Package com.github.luben.zstd
Class RecyclingBufferPool
java.lang.Object
com.github.luben.zstd.RecyclingBufferPool
- All Implemented Interfaces:
BufferPool
A pool of buffers which uses a simple reference queue to recycle buffers.
Do not use it as generic buffer pool - it is optimized and supports only
buffer sizes used by the Zstd classes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
static final BufferPool
private final Deque
<SoftReference<ByteBuffer>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionget
(int capacity) Fetch a buffer from the pool.void
release
(ByteBuffer buffer) Return a buffer to the pool.
-
Field Details
-
INSTANCE
-
buffSize
private static final int buffSize -
pool
-
-
Constructor Details
-
RecyclingBufferPool
private RecyclingBufferPool()
-
-
Method Details
-
get
Description copied from interface:BufferPool
Fetch a buffer from the pool.- Specified by:
get
in interfaceBufferPool
- Parameters:
capacity
- the desired size of the buffer- Returns:
- a heap buffer with size at least the `capacity` and arrayOffset of 0
-
release
Description copied from interface:BufferPool
Return a buffer to the pool.- Specified by:
release
in interfaceBufferPool
- Parameters:
buffer
- the buffer to return
-