Class WriteQueue
java.lang.Object
io.grpc.netty.WriteQueue
A queue of pending writes to a
Channel that is flushed as a single unit.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static interfaceSimple wrapper type around a command and its optional completion listener.private static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final io.netty.channel.Channel(package private) static final intprivate final RunnableRunnableused to schedule work onto the tail of the event loop.private final Queue<WriteQueue.QueuedCommand> private final AtomicBoolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(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 the runnable.private voidflush()Process the queue of commands and dispatch them to the stream.(package private) voidSchedule a flush on the channel.
-
Field Details
-
DEQUE_CHUNK_SIZE
static final int DEQUE_CHUNK_SIZE- See Also:
-
later
-
channel
private final io.netty.channel.Channel channel -
queue
-
scheduled
-
-
Constructor Details
-
WriteQueue
public WriteQueue(io.netty.channel.Channel channel)
-
-
Method Details
-
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
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
-