private void writeNotInEventLoop(ActiveMQBuffer buffer, final boolean flush, final boolean batched, final ChannelFutureListener futureListener) { final Channel channel = this.channel; final ChannelPromise promise; if (flush || (futureListener != null)) { promise = channel.newPromise(); } else { promise = channel.voidPromise(); } final ChannelFuture future; final ByteBuf bytes = buffer.byteBuf(); final int readableBytes = bytes.readableBytes(); assert readableBytes >= 0; final int writeBatchSize = this.batchLimit; final boolean batchingEnabled = this.batchingEnabled; if (batchingEnabled && batched && !flush && readableBytes < writeBatchSize) { future = writeBatch(bytes, readableBytes, promise); } else { future = channel.writeAndFlush(bytes, promise); } if (futureListener != null) { future.addListener(futureListener); } if (flush) { //NOTE: this code path seems used only on RemotingConnection::disconnect waitFor(promise, DEFAULT_WAIT_MILLIS); } }
private static void flushAndWait(final Channel channel, final ChannelPromise promise) { if (!channel.eventLoop().inEventLoop()) { waitFor(promise, DEFAULT_WAIT_MILLIS); } else { if (logger.isDebugEnabled()) { logger.debug("Calling write with flush from a thread where it's not allowed"); } } }
private static void flushAndWait(final Channel channel, final ChannelPromise promise) { if (!channel.eventLoop().inEventLoop()) { waitFor(promise, DEFAULT_WAIT_MILLIS); } else { if (logger.isDebugEnabled()) { logger.debug("Calling write with flush from a thread where it's not allowed"); } } }
private void writeNotInEventLoop(ActiveMQBuffer buffer, final boolean flush, final boolean batched, final ChannelFutureListener futureListener) { final Channel channel = this.channel; final ChannelPromise promise; if (flush || (futureListener != null)) { promise = channel.newPromise(); } else { promise = channel.voidPromise(); } final ChannelFuture future; final ByteBuf bytes = buffer.byteBuf(); final int readableBytes = bytes.readableBytes(); assert readableBytes >= 0; final int writeBatchSize = this.batchLimit; final boolean batchingEnabled = this.batchingEnabled; if (batchingEnabled && batched && !flush && readableBytes < writeBatchSize) { future = writeBatch(bytes, readableBytes, promise); } else { future = channel.writeAndFlush(bytes, promise); } if (futureListener != null) { future.addListener(futureListener); } if (flush) { //NOTE: this code path seems used only on RemotingConnection::disconnect waitFor(promise, DEFAULT_WAIT_MILLIS); } }
private void writeNotInEventLoop(ActiveMQBuffer buffer, final boolean flush, final boolean batched, final ChannelFutureListener futureListener) { final Channel channel = this.channel; final ChannelPromise promise; if (flush || (futureListener != null)) { promise = channel.newPromise(); } else { promise = channel.voidPromise(); } final ChannelFuture future; final ByteBuf bytes = buffer.byteBuf(); final int readableBytes = bytes.readableBytes(); assert readableBytes >= 0; final int writeBatchSize = this.batchLimit; final boolean batchingEnabled = this.batchingEnabled; if (batchingEnabled && batched && !flush && readableBytes < writeBatchSize) { future = writeBatch(bytes, readableBytes, promise); } else { future = channel.writeAndFlush(bytes, promise); } if (futureListener != null) { future.addListener(futureListener); } if (flush) { //NOTE: this code path seems used only on RemotingConnection::disconnect waitFor(promise, DEFAULT_WAIT_MILLIS); } }
private void writeNotInEventLoop(ActiveMQBuffer buffer, final boolean flush, final boolean batched, final ChannelFutureListener futureListener) { final Channel channel = this.channel; final ChannelPromise promise; if (flush || (futureListener != null)) { promise = channel.newPromise(); } else { promise = channel.voidPromise(); } final ChannelFuture future; final ByteBuf bytes = buffer.byteBuf(); final int readableBytes = bytes.readableBytes(); assert readableBytes >= 0; final int writeBatchSize = this.batchLimit; final boolean batchingEnabled = this.batchingEnabled; if (batchingEnabled && batched && !flush && readableBytes < writeBatchSize) { future = writeBatch(bytes, readableBytes, promise); } else { future = channel.writeAndFlush(bytes, promise); } if (futureListener != null) { future.addListener(futureListener); } if (flush) { //NOTE: this code path seems used only on RemotingConnection::disconnect waitFor(promise, DEFAULT_WAIT_MILLIS); } }
private static void flushAndWait(final Channel channel, final ChannelPromise promise) { if (!channel.eventLoop().inEventLoop()) { waitFor(promise, DEFAULT_WAIT_MILLIS); } else { if (logger.isDebugEnabled()) { logger.debug("Calling write with flush from a thread where it's not allowed"); } } }