public interface ByteBufferPool
ByteBuffer
s according to a specific type (direct/heap).
ByteBuffer buffer = pool.borrow(size);
//...using buffer...
pool.release(buffer);
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
borrow(int size,
boolean zeroed)
It returns a
ByteBuffer with Buffer.capacity() >=size .The buffer is zeroed until size if zeroed=true , with Buffer.position() =0 and Buffer.limit() =size . |
void |
release(ByteBuffer buffer)
It pools or free
buffer that cannot be used anymore.If buffer is of a type different from the one that the pool can borrow, it will ignore it. |
static ByteBufferPool |
threadLocal(boolean direct)
Factory method that creates a thread-local pool of capacity 1 of
ByteBuffer s of the specified type (direct/heap). |
ByteBuffer borrow(int size, boolean zeroed)
ByteBuffer
with Buffer.capacity()
>=size
.buffer
is zeroed until size
if zeroed=true
, with Buffer.position()
=0 and Buffer.limit()
=size
.void release(ByteBuffer buffer)
buffer
that cannot be used anymore.buffer
is of a type different from the one that the pool can borrow, it will ignore it.static ByteBufferPool threadLocal(boolean direct)
ByteBuffer
s of the specified type (direct/heap).Copyright © 2020 JBoss by Red Hat. All rights reserved.