public final class CoalescingBufferQueue extends AbstractCoalescingBufferQueue
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(int, io.netty.channel.ChannelPromise) completes.
 
This functionality is useful for aggregating or partitioning writes into fixed size buffers for framing protocols such as HTTP2.
| Constructor and Description | 
|---|
| CoalescingBufferQueue(Channel channel) | 
| CoalescingBufferQueue(Channel channel,
                     int initSize) | 
| CoalescingBufferQueue(Channel channel,
                     int initSize,
                     boolean updateWritability) | 
| Modifier and Type | Method and Description | 
|---|---|
| protected ByteBuf | compose(ByteBufAllocator alloc,
       ByteBuf cumulation,
       ByteBuf next)Calculate the result of  current + next. | 
| void | releaseAndFailAll(Throwable cause)Release all buffers in the queue and complete all listeners and promises. | 
| ByteBuf | remove(int bytes,
      ChannelPromise aggregatePromise)Remove a  ByteBuffrom the queue with the specified number of bytes. | 
| protected ByteBuf | removeEmptyValue()The value to return when  AbstractCoalescingBufferQueue.remove(ByteBufAllocator, int, ChannelPromise)is called but the queue is empty. | 
add, add, add, addFirst, composeFirst, composeFirst, composeIntoComposite, copyAndCompose, copyTo, isEmpty, readableBytes, releaseAndFailAll, remove, removeFirst, size, toString, writeAndRemoveAllpublic CoalescingBufferQueue(Channel channel)
public CoalescingBufferQueue(Channel channel, int initSize)
public CoalescingBufferQueue(Channel channel, int initSize, boolean updateWritability)
public ByteBuf remove(int bytes, ChannelPromise aggregatePromise)
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.bytes - the maximum number of readable bytes in the returned ByteBuf, if bytes is greater
              than AbstractCoalescingBufferQueue.readableBytes then a buffer of length AbstractCoalescingBufferQueue.readableBytes is returned.aggregatePromise - used to aggregate the promises and listeners for the constituent buffers.ByteBuf composed of the enqueued buffers.public void releaseAndFailAll(Throwable cause)
protected ByteBuf compose(ByteBufAllocator alloc, ByteBuf cumulation, ByteBuf next)
AbstractCoalescingBufferQueuecurrent + next.compose in class AbstractCoalescingBufferQueueprotected ByteBuf removeEmptyValue()
AbstractCoalescingBufferQueueAbstractCoalescingBufferQueue.remove(ByteBufAllocator, int, ChannelPromise) is called but the queue is empty.removeEmptyValue in class AbstractCoalescingBufferQueueByteBuf which represents an empty queue.Copyright © 2008–2025 The Netty Project. All rights reserved.