Top Description Fields Constructors Methods
io.netty5.channel

public final Class CoalescingBufferQueue

extends AbstractCoalescingBufferQueue
Class Inheritance
Imports
io.netty5.buffer.Buffer, .BufferAllocator, .CompositeBuffer, io.netty5.util.concurrent.Promise

A FIFO queue of bytes where producers add bytes by repeatedly adding Buffer and consumers take bytes in arbitrary lengths. This allows producers to add lots of small buffers and the consumer to take all the bytes out in a single buffer. Conversely, the producer may add larger buffers and the consumer could take the bytes in many small buffers.

Bytes are added and removed with promises. If the last byte of a buffer added with a promise is removed then that promise will complete when the promise passed to remove completes.

This functionality is useful for aggregating or partitioning writes into fixed size buffers for framing protocols such as HTTP2.

Field Summary

Modifier and TypeField and Description
private final Channel

Constructor Summary

AccessConstructor and Description
public
public
CoalescingBufferQueue(Channel channel, int initSize)

Method Summary

Modifier and TypeMethod and Description
protected Buffer
compose(BufferAllocator alloc, Buffer cumulation, Buffer next)

Implements abstract io.netty5.channel.AbstractCoalescingBufferQueue.compose.

Calculate the result of current + next.
public void
releaseAndFailAll(Throwable cause)

Release all buffers in the queue and complete all listeners and promises.

public Buffer

Returns:

a Buffer composed of the enqueued buffers.
remove
(int
the maximum number of readable bytes in the returned Buffer, if bytes is greater than readableBytes() then a buffer of length readableBytes() is returned.
bytes
,
Promise<Void>
used to aggregate the promises and listeners for the constituent buffers.
aggregatePromise
)

Remove a Buffer from the queue with the specified number of bytes.

protected Buffer
removeEmptyValue()

Implements abstract io.netty5.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

The value to return when remove(BufferAllocator, int, Promise) is called but the queue is empty.
Inherited from io.netty5.channel.AbstractCoalescingBufferQueue:
addaddaddaddFirstcomposeFirstcomposeIntoCompositecopyAndComposecopyToisEmptyreadableBytesreleaseAndFailAllremoveremoveFirstsizetoStringwriteAndRemoveAll

Field Detail

channelback to summary
private final Channel channel

Constructor Detail

CoalescingBufferQueueback to summary
public CoalescingBufferQueue(Channel channel)
CoalescingBufferQueueback to summary
public CoalescingBufferQueue(Channel channel, int initSize)

Method Detail

composeback to summary
protected Buffer compose(BufferAllocator alloc, Buffer cumulation, Buffer next)

Implements abstract io.netty5.channel.AbstractCoalescingBufferQueue.compose.

Doc from io.netty5.channel.AbstractCoalescingBufferQueue.compose.

Calculate the result of current + next.

Annotations
@Override
releaseAndFailAllback to summary
public void releaseAndFailAll(Throwable cause)

Release all buffers in the queue and complete all listeners and promises.

removeback to summary
public Buffer remove(int bytes, Promise<Void> aggregatePromise)

Remove a Buffer from the queue with the specified number of bytes. Any added buffer whose bytes are fully consumed during removal will have it's promise completed when the passed aggregate Promise completes.

Parameters
bytes:int

the maximum number of readable bytes in the returned Buffer, if bytes is greater than readableBytes() then a buffer of length readableBytes() is returned.

aggregatePromise:Promise<Void>

used to aggregate the promises and listeners for the constituent buffers.

Returns:Buffer

a Buffer composed of the enqueued buffers.

removeEmptyValueback to summary
protected Buffer removeEmptyValue()

Implements abstract io.netty5.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

Doc from io.netty5.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

The value to return when remove(BufferAllocator, int, Promise) is called but the queue is empty.

Returns:Buffer

the Buffer which represents an empty queue.

Annotations
@Override