Package com.github.luben.zstd
Class RecyclingBufferPool
- java.lang.Object
-
- com.github.luben.zstd.RecyclingBufferPool
-
- All Implemented Interfaces:
BufferPool
public class RecyclingBufferPool extends java.lang.Object implements 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
Fields Modifier and Type Field Description static BufferPoolINSTANCE
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBufferget(int capacity)Fetch a buffer from the pool.voidrelease(java.nio.ByteBuffer buffer)Return a buffer to the pool.
-
-
-
Field Detail
-
INSTANCE
public static final BufferPool INSTANCE
-
-
Method Detail
-
get
public java.nio.ByteBuffer get(int capacity)
Description copied from interface:BufferPoolFetch a buffer from the pool.- Specified by:
getin interfaceBufferPool- Parameters:
capacity- the desired size of the buffer- Returns:
- a heap buffer with size at least the `capacity` and arrayOffset of 0
-
release
public void release(java.nio.ByteBuffer buffer)
Description copied from interface:BufferPoolReturn a buffer to the pool.- Specified by:
releasein interfaceBufferPool- Parameters:
buffer- the buffer to return
-
-