Top Description Fields Constructors Methods
io.netty.channel

public final Class CoalescingBufferQueue

extends AbstractCoalescingBufferQueue
Class Inheritance
Imports
io.netty.buffer.ByteBuf, .ByteBufAllocator, .CompositeByteBuf, .Unpooled, io.netty.util.internal.ObjectUtil

A FIFO queue of bytes where producers add bytes by repeatedly adding ByteBuf 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)

public
CoalescingBufferQueue(Channel channel, int initSize, boolean updateWritability)

Method Summary

Modifier and TypeMethod and Description
protected ByteBuf
compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next)

Implements abstract io.netty.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 ByteBuf

Returns:

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

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

protected ByteBuf
removeEmptyValue()

Implements abstract io.netty.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

The value to return when remove(ByteBufAllocator, int, ChannelPromise) is called but the queue is empty.
Inherited from io.netty.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)
CoalescingBufferQueueback to summary
public CoalescingBufferQueue(Channel channel, int initSize, boolean updateWritability)

Method Detail

composeback to summary
protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next)

Implements abstract io.netty.channel.AbstractCoalescingBufferQueue.compose.

Doc from io.netty.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 ByteBuf remove(int bytes, ChannelPromise aggregatePromise)

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

Parameters
bytes:int

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

aggregatePromise:ChannelPromise

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

Returns:ByteBuf

a ByteBuf composed of the enqueued buffers.

removeEmptyValueback to summary
protected ByteBuf removeEmptyValue()

Implements abstract io.netty.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

Doc from io.netty.channel.AbstractCoalescingBufferQueue.removeEmptyValue.

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

Returns:ByteBuf

the ByteBuf which represents an empty queue.

Annotations
@Override