Package io.netty.channel
Class PendingWriteQueue
java.lang.Object
io.netty.channel.PendingWriteQueue
A queue of write operations which are pending for later execution. It also updates the
writability of the associated
Channel
, so that
the pending write operations are also considered to determine the writability.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final class
Holds all meta-data and construct the linked-list structure. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate long
private final EventExecutor
private PendingWriteQueue.PendingWrite
private final ChannelOutboundInvoker
private static final InternalLogger
private static final int
private int
private PendingWriteQueue.PendingWrite
private final PendingBytesTracker
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(Object msg, ChannelPromise promise) Add the givenmsg
andChannelPromise
.private void
long
bytes()
Returns the total number of bytes that are pending because of pending messages.current()
Return the current message ornull
if empty.boolean
isEmpty()
Returnstrue
if there are no pending write operations left in this queue.private void
recycle
(PendingWriteQueue.PendingWrite write, boolean update) remove()
Removes a pending write operation and release it's message viaReferenceCountUtil.safeRelease(Object)
.void
removeAndFail
(Throwable cause) Remove a pending write operation and fail it with the givenThrowable
.void
removeAndFailAll
(Throwable cause) Remove all pending write operation and fail them with the givenThrowable
.Removes a pending write operation and performs it viaChannelOutboundInvoker.write(Object, ChannelPromise)
.Remove all pending write operation and performs them viaChannelOutboundInvoker.write(Object, ChannelPromise)
.private static void
safeFail
(ChannelPromise promise, Throwable cause) int
size()
Returns the number of pending write operations.private int
-
Field Details
-
logger
-
PENDING_WRITE_OVERHEAD
private static final int PENDING_WRITE_OVERHEAD -
invoker
-
executor
-
tracker
-
head
-
tail
-
size
private int size -
bytes
private long bytes
-
-
Constructor Details
-
PendingWriteQueue
-
PendingWriteQueue
-
-
Method Details
-
isEmpty
public boolean isEmpty()Returnstrue
if there are no pending write operations left in this queue. -
size
public int size()Returns the number of pending write operations. -
bytes
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. -
size
-
add
Add the givenmsg
andChannelPromise
. -
removeAndWriteAll
Remove all pending write operation and performs them viaChannelOutboundInvoker.write(Object, ChannelPromise)
.- Returns:
ChannelFuture
if something was written andnull
if thePendingWriteQueue
is empty.
-
removeAndFailAll
Remove all pending write operation and fail them with the givenThrowable
. The message will be released viaReferenceCountUtil.safeRelease(Object)
. -
removeAndFail
Remove a pending write operation and fail it with the givenThrowable
. The message will be released viaReferenceCountUtil.safeRelease(Object)
. -
assertEmpty
private void assertEmpty() -
removeAndWrite
Removes a pending write operation and performs it viaChannelOutboundInvoker.write(Object, ChannelPromise)
.- Returns:
ChannelFuture
if something was written andnull
if thePendingWriteQueue
is empty.
-
remove
Removes a pending write operation and release it's message viaReferenceCountUtil.safeRelease(Object)
.- Returns:
ChannelPromise
of the pending write ornull
if the queue is empty.
-
current
Return the current message ornull
if empty. -
recycle
-
safeFail
-