Top Description Inners Fields Constructors Methods
io.netty5.channel

public final Class PendingWriteQueue

extends Object
Class Inheritance
Imports
io.netty5.util.Resource, io.netty5.util.concurrent.EventExecutor, .Future, .Promise, .PromiseCombiner, io.netty5.util.internal.ObjectPool, .SilentDispose, .SystemPropertyUtil, io.netty5.util.internal.logging.InternalLogger, .InternalLoggerFactory, java.util.Objects, java.util.function.Function

A queue of write operations which are pending for later execution.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
PendingWriteQueue.PendingWrite

Holds all meta-data and construct the linked-list structure.

Field Summary

Modifier and TypeField and Description
private long
private final EventExecutor
private PendingWriteQueue.PendingWrite
private static final InternalLogger
private static final int
private int
private final MessageSizeEstimator.Handle
private PendingWriteQueue.PendingWrite

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(Object msg, Promise<Void> promise)

Add the given msg and Promise.

private void
public long
bytes()

Returns the total number of bytes that are pending because of pending messages.

public Object
current()

Return the current message or null if empty.

public boolean
isEmpty()

Returns true if there are no pending write operations left in this queue.

private void
recycle(PendingWriteQueue.PendingWrite write, boolean update)

public Promise<Void>

Returns:

Promise of the pending write or null if the queue is empty.
remove
()

Removes a pending write operation and release its message via Resource#dispose(Object).

public void
removeAndFail(Throwable cause)

Remove a pending write operation and fail it with the given Throwable.

public void
removeAndFailAll(Throwable cause)

Remove all pending write operation and fail them with the given Throwable.

public Future<Void>

Returns:

Future if something was transfered and null if the PendingWriteQueue is empty.
removeAndTransfer
(Function<Object, Future<Void>> transferFunc)

Removes a pending write operation and performs it via Function#apply(Object).

public Future<Void>

Returns:

Future if something was transferred and null if the PendingWriteQueue is empty.
removeAndTransferAll
(Function<Object, Future<Void>> transferFunc)

Remove all pending write operation and performs them via Function#apply(Object).

private static void
safeFail(Promise<Void> promise, Throwable cause)

public int
size()

Returns the number of pending write operations.

private int
size(Object msg)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bytesback to summary
private long bytes
executorback to summary
private final EventExecutor executor
loggerback to summary
private static final InternalLogger logger
PENDING_WRITE_OVERHEADback to summary
private static final int PENDING_WRITE_OVERHEAD
sizeback to summary
private int size
sizeEstimatorHandleback to summary
private final MessageSizeEstimator.Handle sizeEstimatorHandle
tailback to summary
private PendingWriteQueue.PendingWrite tail

Constructor Detail

PendingWriteQueueback to summary
public PendingWriteQueue(EventExecutor executor, MessageSizeEstimator.Handle handle)

Method Detail

addback to summary
public void add(Object msg, Promise<Void> promise)

Add the given msg and Promise.

assertEmptyback to summary
private void assertEmpty()
bytesback to summary
public long bytes()

Returns the total number of bytes that are pending because of pending messages. This is only an estimate so it should only be treated as a hint.

currentback to summary
public Object current()

Return the current message or null if empty.

isEmptyback to summary
public boolean isEmpty()

Returns true if there are no pending write operations left in this queue.

recycleback to summary
private void recycle(PendingWriteQueue.PendingWrite write, boolean update)
removeback to summary
public Promise<Void> remove()

Removes a pending write operation and release its message via Resource#dispose(Object).

Returns:Promise<Void>

Promise of the pending write or null if the queue is empty.

removeAndFailback to summary
public void removeAndFail(Throwable cause)

Remove a pending write operation and fail it with the given Throwable. The message will be released via Resource#dispose(Object).

removeAndFailAllback to summary
public void removeAndFailAll(Throwable cause)

Remove all pending write operation and fail them with the given Throwable. The message will be released via Resource#dispose(Object).

removeAndTransferback to summary
public Future<Void> removeAndTransfer(Function<Object, Future<Void>> transferFunc)

Removes a pending write operation and performs it via Function#apply(Object).

Returns:Future<Void>

Future if something was transfered and null if the PendingWriteQueue is empty.

removeAndTransferAllback to summary
public Future<Void> removeAndTransferAll(Function<Object, Future<Void>> transferFunc)

Remove all pending write operation and performs them via Function#apply(Object).

Returns:Future<Void>

Future if something was transferred and null if the PendingWriteQueue is empty.

safeFailback to summary
private static void safeFail(Promise<Void> promise, Throwable cause)
sizeback to summary
public int size()

Returns the number of pending write operations.

sizeback to summary
private int size(Object msg)
io.netty5.channel back to summary

pack-priv final Class PendingWriteQueue.PendingWrite

extends Object
Class Inheritance

Holds all meta-data and construct the linked-list structure.

Field Summary

Modifier and TypeField and Description
private final ObjectPool.Handle<PendingWriteQueue.PendingWrite>
private Object
private PendingWriteQueue.PendingWrite
private Promise<Void>
private static final ObjectPool<PendingWriteQueue.PendingWrite>
private long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static PendingWriteQueue.PendingWrite
newInstance(Object msg, int size, Promise<Void> promise)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handleback to summary
private final ObjectPool.Handle<PendingWriteQueue.PendingWrite> handle
msgback to summary
private Object msg
nextback to summary
private PendingWriteQueue.PendingWrite next
promiseback to summary
private Promise<Void> promise
RECYCLERback to summary
private static final ObjectPool<PendingWriteQueue.PendingWrite> RECYCLER
sizeback to summary
private long size

Constructor Detail

PendingWriteback to summary
private PendingWrite(ObjectPool.Handle<PendingWriteQueue.PendingWrite> handle)

Method Detail

newInstanceback to summary
pack-priv static PendingWriteQueue.PendingWrite newInstance(Object msg, int size, Promise<Void> promise)
recycleback to summary
private void recycle()