Package io.netty.channel
Class PendingWriteQueue
- java.lang.Object
-
- io.netty.channel.PendingWriteQueue
-
public final class PendingWriteQueue extends java.lang.Object
A queue of write operations which are pending for later execution. It also updates the writability of the associatedChannel
, so that the pending write operations are also considered to determine the writability.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
PendingWriteQueue.PendingWrite
Holds all meta-data and construct the linked-list structure.
-
Field Summary
Fields Modifier and Type Field Description private long
bytes
private EventExecutor
executor
private PendingWriteQueue.PendingWrite
head
private ChannelOutboundInvoker
invoker
private static InternalLogger
logger
private static int
PENDING_WRITE_OVERHEAD
private int
size
private PendingWriteQueue.PendingWrite
tail
private PendingBytesTracker
tracker
-
Constructor Summary
Constructors Constructor Description PendingWriteQueue(Channel channel)
PendingWriteQueue(ChannelHandlerContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(java.lang.Object msg, ChannelPromise promise)
Add the givenmsg
andChannelPromise
.private void
assertEmpty()
long
bytes()
Returns the total number of bytes that are pending because of pending messages.java.lang.Object
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)
ChannelPromise
remove()
Removes a pending write operation and release it's message viaReferenceCountUtil.safeRelease(Object)
.void
removeAndFail(java.lang.Throwable cause)
Remove a pending write operation and fail it with the givenThrowable
.void
removeAndFailAll(java.lang.Throwable cause)
Remove all pending write operation and fail them with the givenThrowable
.ChannelFuture
removeAndWrite()
Removes a pending write operation and performs it viaChannelOutboundInvoker.write(Object, ChannelPromise)
.ChannelFuture
removeAndWriteAll()
Remove all pending write operation and performs them viaChannelOutboundInvoker.write(Object, ChannelPromise)
.private static void
safeFail(ChannelPromise promise, java.lang.Throwable cause)
int
size()
Returns the number of pending write operations.private int
size(java.lang.Object msg)
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
PENDING_WRITE_OVERHEAD
private static final int PENDING_WRITE_OVERHEAD
-
invoker
private final ChannelOutboundInvoker invoker
-
executor
private final EventExecutor executor
-
tracker
private final PendingBytesTracker tracker
-
head
private PendingWriteQueue.PendingWrite head
-
tail
private PendingWriteQueue.PendingWrite tail
-
size
private int size
-
bytes
private long bytes
-
-
Constructor Detail
-
PendingWriteQueue
public PendingWriteQueue(ChannelHandlerContext ctx)
-
PendingWriteQueue
public PendingWriteQueue(Channel channel)
-
-
Method Detail
-
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
private int size(java.lang.Object msg)
-
add
public void add(java.lang.Object msg, ChannelPromise promise)
Add the givenmsg
andChannelPromise
.
-
removeAndWriteAll
public ChannelFuture 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
public void removeAndFailAll(java.lang.Throwable cause)
Remove all pending write operation and fail them with the givenThrowable
. The message will be released viaReferenceCountUtil.safeRelease(Object)
.
-
removeAndFail
public void removeAndFail(java.lang.Throwable cause)
Remove a pending write operation and fail it with the givenThrowable
. The message will be released viaReferenceCountUtil.safeRelease(Object)
.
-
assertEmpty
private void assertEmpty()
-
removeAndWrite
public ChannelFuture 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
public ChannelPromise 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
public java.lang.Object current()
Return the current message ornull
if empty.
-
recycle
private void recycle(PendingWriteQueue.PendingWrite write, boolean update)
-
safeFail
private static void safeFail(ChannelPromise promise, java.lang.Throwable cause)
-
-