Top Description Fields Constructors Methods
com.github.luben.zstd

public Class RecyclingBufferPool

extends Object
implements BufferPool
Class Inheritance
All Implemented Interfaces
com.github.luben.zstd.BufferPool
Imports
java.lang.ref.SoftReference, java.nio.ByteBuffer, java.util.concurrent.ConcurrentLinkedQueue

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

Modifier and TypeField and Description
private static final int
public static final BufferPool
private final ConcurrentLinkedQueue<SoftReference<ByteBuffer>>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ByteBuffer
get(int
the desired size of the buffer
capacity
)

Implements com.github.luben.zstd.BufferPool.get.

Fetch a buffer from the pool.
public void
release(ByteBuffer
the buffer to return
buffer
)

Implements com.github.luben.zstd.BufferPool.release.

Return a buffer to the pool.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

buffSizeback to summary
private static final int buffSize
INSTANCEback to summary
public static final BufferPool INSTANCE
poolback to summary
private final ConcurrentLinkedQueue<SoftReference<ByteBuffer>> pool

Constructor Detail

RecyclingBufferPoolback to summary
private RecyclingBufferPool()

Method Detail

getback to summary
public ByteBuffer get(int capacity)

Implements com.github.luben.zstd.BufferPool.get.

Doc from com.github.luben.zstd.BufferPool.get.

Fetch a buffer from the pool.

Parameters
capacity:int

the desired size of the buffer

Returns:ByteBuffer

a heap buffer with size at least the `capacity` and arrayOffset of 0

Annotations
@Override
releaseback to summary
public void release(ByteBuffer buffer)

Implements com.github.luben.zstd.BufferPool.release.

Doc from com.github.luben.zstd.BufferPool.release.

Return a buffer to the pool.

Parameters
buffer:ByteBuffer

the buffer to return

Annotations
@Override