Package io.grpc.netty
Class WriteQueue
- java.lang.Object
-
- io.grpc.netty.WriteQueue
-
class WriteQueue extends java.lang.ObjectA queue of pending writes to aChannelthat is flushed as a single unit.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classWriteQueue.AbstractQueuedCommand(package private) static interfaceWriteQueue.QueuedCommandSimple wrapper type around a command and its optional completion listener.private static classWriteQueue.RunnableCommand
-
Field Summary
Fields Modifier and Type Field Description private io.netty.channel.Channelchannel(package private) static intDEQUE_CHUNK_SIZEprivate java.lang.RunnablelaterRunnableused to schedule work onto the tail of the event loop.private java.util.Queue<WriteQueue.QueuedCommand>queueprivate java.util.concurrent.atomic.AtomicBooleanscheduled
-
Constructor Summary
Constructors Constructor Description WriteQueue(io.netty.channel.Channel channel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voiddrainNow()Executes enqueued work directly on the current thread.(package private) io.netty.channel.ChannelFutureenqueue(WriteQueue.QueuedCommand command, boolean flush)Enqueue a write command on the channel.(package private) voidenqueue(java.lang.Runnable runnable, boolean flush)Enqueue the runnable.private voidflush()Process the queue of commands and dispatch them to the stream.(package private) voidscheduleFlush()Schedule a flush on the channel.
-
-
-
Field Detail
-
DEQUE_CHUNK_SIZE
static final int DEQUE_CHUNK_SIZE
- See Also:
- Constant Field Values
-
later
private final java.lang.Runnable later
Runnableused to schedule work onto the tail of the event loop.
-
channel
private final io.netty.channel.Channel channel
-
queue
private final java.util.Queue<WriteQueue.QueuedCommand> queue
-
scheduled
private final java.util.concurrent.atomic.AtomicBoolean scheduled
-
-
Method Detail
-
scheduleFlush
void scheduleFlush()
Schedule a flush on the channel.
-
enqueue
@CanIgnoreReturnValue io.netty.channel.ChannelFuture enqueue(WriteQueue.QueuedCommand command, boolean flush)
Enqueue a write command on the channel.- Parameters:
command- a write to be executed on the channel.flush- true if a flush of the write should be schedule, false if a later call to enqueue will schedule the flush.
-
enqueue
void enqueue(java.lang.Runnable runnable, boolean flush)Enqueue the runnable. It is not safe for another thread to queue an Runnable directly to the event loop, because it will be out-of-order with writes. This method allows the Runnable to be processed in-order with writes.
-
drainNow
void drainNow()
Executes enqueued work directly on the current thread. This can be used to trigger writes before performing additional reads. Must be called from the event loop. This method makes no guarantee that the work queue is empty when it returns.
-
flush
private void flush()
Process the queue of commands and dispatch them to the stream. This method is only called in the event loop
-
-