Interface ByteBufferPool
-
public interface ByteBufferPoolObject Pool that allows to borrow and releaseByteBuffers according to a specific type (direct/heap).
The suggested usage pattern is:ByteBuffer buffer = pool.borrow(size); //...using buffer... pool.release(buffer);
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.nio.ByteBufferborrow(int size, boolean zeroed)It returns aByteBufferwithBuffer.capacity()>=size.
Thebufferis zeroed untilsizeifzeroed=true, withBuffer.position()=0 andBuffer.limit()=size.voidrelease(java.nio.ByteBuffer buffer)It pools or freebufferthat cannot be used anymore.
Ifbufferis of a type different from the one that the pool can borrow, it will ignore it.static ByteBufferPoolthreadLocal(boolean direct)Factory method that creates a thread-local pool of capacity 1 ofByteBuffers of the specified type (direct/heap).
-
-
-
Method Detail
-
borrow
java.nio.ByteBuffer borrow(int size, boolean zeroed)It returns aByteBufferwithBuffer.capacity()>=size.
Thebufferis zeroed untilsizeifzeroed=true, withBuffer.position()=0 andBuffer.limit()=size.
-
release
void release(java.nio.ByteBuffer buffer)
It pools or freebufferthat cannot be used anymore.
Ifbufferis of a type different from the one that the pool can borrow, it will ignore it.
-
threadLocal
static ByteBufferPool threadLocal(boolean direct)
Factory method that creates a thread-local pool of capacity 1 ofByteBuffers of the specified type (direct/heap).
-
-