Top Fields Constructors Methods
io.netty5.channel

public abstract Class AbstractCoalescingBufferQueue

extends Object
Class Inheritance
Known Direct Subclasses
io.netty5.channel.CoalescingBufferQueue
Annotations
@SuppressWarnings:unchecked
@UnstableApi
Imports
io.netty5.buffer.Buffer, .BufferAllocator, .CompositeBuffer, io.netty5.util.concurrent.Future, .FutureListener, .Promise, io.netty5.util.internal.SilentDispose, .UnstableApi, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.ArrayDeque, .List

Field Summary

Modifier and TypeField and Description
private final ArrayDeque<Object>
private static final InternalLogger
private int

Constructor Summary

AccessConstructor and Description
protected
AbstractCoalescingBufferQueue(int
the initial size of the underlying queue.
initSize
)

Create a new instance.

Method Summary

Modifier and TypeMethod and Description
public final void
add(Buffer buf)

Add a buffer to the end of the queue.

public final void
add(Buffer
to add to the tail of the queue
buf
,
Promise<Void>
to complete when all the bytes have been consumed and written, can be void.
promise
)

Add a buffer to the end of the queue and associate a promise with it that should be completed when all the buffer's bytes have been consumed from the queue and written.

public final void
add(Buffer
to add to the tail of the queue
buf
,
FutureListener<Void>
to notify when all the bytes have been consumed and written, can be null.
listener
)

Add a buffer to the end of the queue and associate a listener with it that should be completed when all the buffers bytes have been consumed from the queue and written.

public final void
addFirst(Buffer
to add to the head of the queue
buf
,
Promise<Void>
to complete when all the bytes have been consumed and written, can be void.
promise
)

Add a buffer to the front of the queue and associate a promise with it that should be completed when all the buffer's bytes have been consumed from the queue and written.

private void
protected abstract Buffer
compose(BufferAllocator alloc, Buffer cumulation, Buffer next)

Calculate the result of current + next.

protected Buffer
composeFirst(BufferAllocator allocator, Buffer first)

Calculate the first Buffer which will be used in subsequent calls to compose(BufferAllocator, Buffer, Buffer).

protected final Buffer
composeIntoComposite(BufferAllocator alloc, Buffer cumulation, Buffer next)

Compose cumulation and next into a new CompositeBuffer.

protected final Buffer

Returns:

The result of cumulation + next.
copyAndCompose
(BufferAllocator
The allocator to use to allocate the new buffer.
alloc
,
Buffer
The current cumulation.
cumulation
,
Buffer
The next buffer.
next
,
int
The minimum buffer size - the resulting buffer will grow by at least this much.
minIncrement
)

Compose cumulation and next into a new Buffer suitable for IO.

public final void
copyTo(AbstractCoalescingBufferQueue
to copy pending buffers to.
dest
)

Copy all pending entries in this queue into the destination queue.

private void
decrementReadableBytes(int decrement)

private void
incrementReadableBytes(int increment)

public final boolean
isEmpty()

Are there pending buffers in the queue.

public final int
readableBytes()

The number of readable bytes.

private void
public final void
releaseAndFailAll(ChannelOutboundInvoker invoker, Throwable cause)

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

public final Buffer

Returns:

a Buffer composed of the enqueued buffers.
remove
(BufferAllocator
The allocator used if a new Buffer is generated during the aggregation process.
alloc
,
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 abstract Buffer

Returns:

the Buffer which represents an empty queue.
removeEmptyValue
()

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

public final Buffer

Returns:

the first Buffer from the queue.
removeFirst
(Promise<Void>
used to aggregate the promises and listeners for the returned buffer.
aggregatePromise
)

Remove the first Buffer from the queue.

protected final int

Returns:

the number of elements in this queue.
size
()

Get the number of elements in this queue added via one of the add(Buffer) methods.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public final void
writeAndRemoveAll(ChannelHandlerContext
The context to write all elements to.
ctx
)

Writes all remaining elements in this queue.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

bufAndListenerPairsback to summary
private final ArrayDeque<Object> bufAndListenerPairs
loggerback to summary
private static final InternalLogger logger
readableBytesback to summary
private int readableBytes

Constructor Detail

AbstractCoalescingBufferQueueback to summary
protected AbstractCoalescingBufferQueue(int initSize)

Create a new instance.

Parameters
initSize:int

the initial size of the underlying queue.

Method Detail

addback to summary
public final void add(Buffer buf)

Add a buffer to the end of the queue.

addback to summary
public final void add(Buffer buf, Promise<Void> promise)

Add a buffer to the end of the queue and associate a promise with it that should be completed when all the buffer's bytes have been consumed from the queue and written.

Parameters
buf:Buffer

to add to the tail of the queue

promise:Promise<Void>

to complete when all the bytes have been consumed and written, can be void.

addback to summary
public final void add(Buffer buf, FutureListener<Void> listener)

Add a buffer to the end of the queue and associate a listener with it that should be completed when all the buffers bytes have been consumed from the queue and written.

Parameters
buf:Buffer

to add to the tail of the queue

listener:FutureListener<Void>

to notify when all the bytes have been consumed and written, can be null.

addFirstback to summary
public final void addFirst(Buffer buf, Promise<Void> promise)

Add a buffer to the front of the queue and associate a promise with it that should be completed when all the buffer's bytes have been consumed from the queue and written.

Parameters
buf:Buffer

to add to the head of the queue

promise:Promise<Void>

to complete when all the bytes have been consumed and written, can be void.

addFirstback to summary
private void addFirst(Buffer buf, FutureListener<Void> listener)
composeback to summary
protected abstract Buffer compose(BufferAllocator alloc, Buffer cumulation, Buffer next)

Calculate the result of current + next.

composeFirstback to summary
protected Buffer composeFirst(BufferAllocator allocator, Buffer first)

Calculate the first Buffer which will be used in subsequent calls to compose(BufferAllocator, Buffer, Buffer).

composeIntoCompositeback to summary
protected final Buffer composeIntoComposite(BufferAllocator alloc, Buffer cumulation, Buffer next)

Compose cumulation and next into a new CompositeBuffer.

copyAndComposeback to summary
protected final Buffer copyAndCompose(BufferAllocator alloc, Buffer cumulation, Buffer next, int minIncrement)

Compose cumulation and next into a new Buffer suitable for IO.

Parameters
alloc:BufferAllocator

The allocator to use to allocate the new buffer.

cumulation:Buffer

The current cumulation.

next:Buffer

The next buffer.

minIncrement:int

The minimum buffer size - the resulting buffer will grow by at least this much.

Returns:Buffer

The result of cumulation + next.

copyToback to summary
public final void copyTo(AbstractCoalescingBufferQueue dest)

Copy all pending entries in this queue into the destination queue.

Parameters
dest:AbstractCoalescingBufferQueue

to copy pending buffers to.

decrementReadableBytesback to summary
private void decrementReadableBytes(int decrement)
incrementReadableBytesback to summary
private void incrementReadableBytes(int increment)
isEmptyback to summary
public final boolean isEmpty()

Are there pending buffers in the queue.

readableBytesback to summary
public final int readableBytes()

The number of readable bytes.

releaseAndCompleteAllback to summary
private void releaseAndCompleteAll(Future<Void> future)
releaseAndFailAllback to summary
public final void releaseAndFailAll(ChannelOutboundInvoker invoker, Throwable cause)

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

removeback to summary
public final Buffer remove(BufferAllocator alloc, 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 their promise completed when the passed aggregate Promise completes.

Parameters
alloc:BufferAllocator

The allocator used if a new Buffer is generated during the aggregation process.

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 abstract Buffer 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.

removeFirstback to summary
public final Buffer removeFirst(Promise<Void> aggregatePromise)

Remove the first Buffer from the queue.

Parameters
aggregatePromise:Promise<Void>

used to aggregate the promises and listeners for the returned buffer.

Returns:Buffer

the first Buffer from the queue.

sizeback to summary
protected final int size()

Get the number of elements in this queue added via one of the add(Buffer) methods.

Returns:int

the number of elements in this queue.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeAndRemoveAllback to summary
public final void writeAndRemoveAll(ChannelHandlerContext ctx)

Writes all remaining elements in this queue.

Parameters
ctx:ChannelHandlerContext

The context to write all elements to.