Enqueue a write command on the channel. @param command a write to be executed on the channel. @param flush true if a flush of the write should be schedule, false if a later call to enqueue will schedule the flush.
(QueuedCommand command, boolean flush)
| 77 | * enqueue will schedule the flush. |
| 78 | */ |
| 79 | @CanIgnoreReturnValue |
| 80 | ChannelFuture enqueue(QueuedCommand command, boolean flush) { |
| 81 | // Detect erroneous code that tries to reuse command objects. |
| 82 | Preconditions.checkArgument(command.promise() == null, "promise must not be set on command"); |
| 83 | |
| 84 | ChannelPromise promise = channel.newPromise(); |
| 85 | command.promise(promise); |
| 86 | queue.add(command); |
| 87 | if (flush) { |
| 88 | scheduleFlush(); |
| 89 | } |
| 90 | return promise; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Enqueue the runnable. It is not safe for another thread to queue an Runnable directly to the |