public interface IByteBufferAllocator
ByteBuffer
s used by the sessions for I/O
operations.
The implementation should be thread safe.
Modifier and Type | Method and Description |
---|---|
ByteBuffer |
allocate(int capacity)
Allocates a new byte buffer.
|
ByteBuffer |
ensure(ByteBuffer buffer,
int size,
int minCapacity,
int maxCapacity)
Assures that returned buffer will contain room for new data.
|
ByteBuffer |
ensureSome(ByteBuffer buffer,
int minCapacity,
int maxCapacity)
Ensures that returned buffer will contain some room for new data.
|
ByteBuffer |
extend(ByteBuffer buffer,
int maxCapacity)
Extends the capacity of the buffer based on its current capacity.
|
boolean |
isReleasable()
Tells if an implementation of the allocator supports releasing of no
longer used buffers.
|
ByteBuffer |
reduce(ByteBuffer buffer,
int minCapacity)
Tries to reduce the capacity of the buffer based on its content.
|
void |
release(ByteBuffer buffer)
Informs that given buffer that was allocated by this allocator is no
longer used and can be released.
|
boolean |
usesArray()
Tells whether or not this allocator allocates buffers that are backed by
an accessible byte array.
|
boolean usesArray()
ByteBuffer allocate(int capacity)
capacity
- The new buffer's capacity, in bytesboolean isReleasable()
true
if the releasing is supportedvoid release(ByteBuffer buffer)
buffer
- buffer to be releasedByteBuffer ensureSome(ByteBuffer buffer, int minCapacity, int maxCapacity)
IndexOutOfBoundsException
.
It is only used to manage the capacity of the input buffer associated with the stream-oriented sessions.
buffer
- buffer in the write mode (i.e. not flipped yet)minCapacity
- min capacitymaxCapacity
- max capacityIndexOutOfBoundsException
- if the buffer is full and its capacity reached the max
capacityByteBuffer ensure(ByteBuffer buffer, int size, int minCapacity, int maxCapacity)
IndexOutOfBoundsException
.
It is only used to manage the capacity of the input buffer associated with the engine driven stream-oriented sessions.
buffer
- buffer in the write mode (i.e. not flipped yet)size
- size of data to be put to the bufferminCapacity
- min capacitymaxCapacity
- max capacityIndexOutOfBoundsException
- if there is no room in the buffer for the new dataByteBuffer reduce(ByteBuffer buffer, int minCapacity)
It is only used to manage the capacity of the output buffers associated with the stream-oriented sessions.
buffer
- buffer in the write mode (i.e. not flipped yet)minCapacity
- min capacityByteBuffer extend(ByteBuffer buffer, int maxCapacity)
It is only used to manage the capacity of the input buffer associated with the datagram-oriented sessions. The method is called after receiving a datagram that fully filled up the input buffer.
buffer
- buffer in the write mode (i.e. not flipped yet)maxCapacity
- max capacityCopyright © 2017–2022 SNF4J.ORG. All rights reserved.