Top Description Methods
io.netty5.channel

public Interface ReadBufferAllocator

Imports
io.netty5.buffer.Buffer, .BufferAllocator

Implementations of this interface can influence how Buffers are allocated that are used when reading from the transport.

Method Summary

Modifier and TypeMethod and Description
public Buffer

Returns:

the Buffer that will be used or null if the read should not happen until the next ChannelOutboundInvoker#read(ReadBufferAllocator) call is done.
allocate
(BufferAllocator
The BufferAllocator that might be used for the allocation. While its fine to not use the BufferAllocator it is important that the returned Buffer matches the BufferAllocator#getAllocationType() of the allocator.
allocator
,
int
the estimated capacity for the buffer. This is just a best guess and users might decide to use their own capacity.
estimatedCapacity
)

Allocates a Buffer that is used for the next actual read to store the data in.

public static ReadBufferAllocator
exact(int
the number of bytes that can be written.
numBytes
)

Return a ReadBufferAllocator that will return a Buffer that has exact numBytes of writable bytes.

Method Detail

allocateback to summary
public Buffer allocate(BufferAllocator allocator, int estimatedCapacity)

Allocates a Buffer that is used for the next actual read to store the data in.

Parameters
allocator:BufferAllocator

The BufferAllocator that might be used for the allocation. While its fine to not use the BufferAllocator it is important that the returned Buffer matches the BufferAllocator#getAllocationType() of the allocator.

estimatedCapacity:int

the estimated capacity for the buffer. This is just a best guess and users might decide to use their own capacity.

Returns:Buffer

the Buffer that will be used or null if the read should not happen until the next ChannelOutboundInvoker#read(ReadBufferAllocator) call is done.

exactback to summary
public static ReadBufferAllocator exact(int numBytes)

Return a ReadBufferAllocator that will return a Buffer that has exact numBytes of writable bytes.

Parameters
numBytes:int

the number of bytes that can be written.

Returns:ReadBufferAllocator

a ReadBufferAllocator.