Package io.grpc.netty

Class WriteQueue

java.lang.Object
io.grpc.netty.WriteQueue

class WriteQueue extends Object
A queue of pending writes to a Channel that is flushed as a single unit.
  • Field Details

  • 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

      void enqueue(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