/** * Returns {@code true} if there are no pending write operations left in this queue. */ public boolean isEmpty() { assert ctx.executor().inEventLoop(); return head == null; }
static void invokeChannelActive(final AbstractChannelHandlerContext next) { EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeChannelActive(); } else { executor.execute(new Runnable() { @Override public void run() { next.invokeChannelActive(); } }); } }
final void remove() { EventExecutor executor = executor(); if (executor.inEventLoop()) { remove0(); } else { executor.execute(new Runnable() { @Override public void run() { remove0(); } }); } }
void writePriority(Http2Stream stream, int streamDependency, short weight, boolean exclusive) { EventExecutor executor = chctx.executor(); if (executor.inEventLoop()) { _writePriority(stream, streamDependency, weight, exclusive); } else { executor.execute(() -> { _writePriority(stream, streamDependency, weight, exclusive); }); } } }
@Override public ChannelFuture bind(final SocketAddress localAddress, final ChannelPromise promise) { if (localAddress == null) { throw new NullPointerException("localAddress"); } if (isNotValidPromise(promise, false)) { // cancelled return promise; } final AbstractChannelHandlerContext next = findContextOutbound(); EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeBind(localAddress, promise); } else { safeExecute(executor, new Runnable() { @Override public void run() { next.invokeBind(localAddress, promise); } }, promise, null); } return promise; }
void writeHeaders(Http2Stream stream, Http2Headers headers, boolean end, int streamDependency, short weight, boolean exclusive) { EventExecutor executor = chctx.executor(); if (executor.inEventLoop()) { _writeHeaders(stream, headers, end, streamDependency, weight, exclusive); } else { executor.execute(() -> { _writeHeaders(stream, headers, end, streamDependency, weight, exclusive); }); } }
/** * Returns the number of pending write operations. */ public int size() { assert ctx.executor().inEventLoop(); return size; }
static void invokeChannelInactive(final AbstractChannelHandlerContext next) { EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeChannelInactive(); } else { executor.execute(new Runnable() { @Override public void run() { next.invokeChannelInactive(); } }); } }
@Override public Future<Channel> acquire(final Promise<Channel> promise) { try { if (executor.inEventLoop()) { acquire0(promise); } else { executor.execute(new Runnable() { @Override public void run() { acquire0(promise); } }); } } catch (Throwable cause) { promise.setFailure(cause); } return promise; }
@Override public ChannelFuture connect( final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) { if (remoteAddress == null) { throw new NullPointerException("remoteAddress"); } if (isNotValidPromise(promise, false)) { // cancelled return promise; } final AbstractChannelHandlerContext next = findContextOutbound(); EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeConnect(remoteAddress, localAddress, promise); } else { safeExecute(executor, new Runnable() { @Override public void run() { next.invokeConnect(remoteAddress, localAddress, promise); } }, promise, null); } return promise; }
void writeReset(int streamId, long code) { EventExecutor executor = chctx.executor(); if (executor.inEventLoop()) { _writeReset(streamId, code); } else { executor.execute(() -> { _writeReset(streamId, code); }); } }
/** * Return the current message or {@code null} if empty. */ public Object current() { assert ctx.executor().inEventLoop(); PendingWrite write = head; if (write == null) { return null; } return write.msg; }
static void invokeChannelUnregistered(final AbstractChannelHandlerContext next) { EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeChannelUnregistered(); } else { executor.execute(new Runnable() { @Override public void run() { next.invokeChannelUnregistered(); } }); } }
final void remove() { EventExecutor executor = executor(); if (executor.inEventLoop()) { remove0(); } else { executor.execute(new Runnable() { @Override public void run() { remove0(); } }); } }
@Override public ChannelFuture deregister(final ChannelPromise promise) { if (isNotValidPromise(promise, false)) { // cancelled return promise; } final AbstractChannelHandlerContext next = findContextOutbound(); EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeDeregister(promise); } else { safeExecute(executor, new Runnable() { @Override public void run() { next.invokeDeregister(promise); } }, promise, null); } return promise; }
void writeFrame(Http2Stream stream, byte type, short flags, ByteBuf payload) { EventExecutor executor = chctx.executor(); if (executor.inEventLoop()) { _writeFrame(stream, type, flags, payload); } else { executor.execute(() -> { _writeFrame(stream, type, flags, payload); }); } }
/** * Returns the total number of bytes that are pending because of pending messages. This is only an estimate so * it should only be treated as a hint. */ public long bytes() { assert ctx.executor().inEventLoop(); return bytes; }
static void invokeChannelRegistered(final AbstractChannelHandlerContext next) { EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeChannelRegistered(); } else { executor.execute(new Runnable() { @Override public void run() { next.invokeChannelRegistered(); } }); } }
@Override public ChannelFuture close(final ChannelPromise promise) { if (isNotValidPromise(promise, false)) { // cancelled return promise; } final AbstractChannelHandlerContext next = findContextOutbound(); EventExecutor executor = next.executor(); if (executor.inEventLoop()) { next.invokeClose(promise); } else { safeExecute(executor, new Runnable() { @Override public void run() { next.invokeClose(promise); } }, promise, null); } return promise; }
void writeGoAway(long errorCode, int lastStreamId, ByteBuf debugData) { EventExecutor executor = chctx.executor(); if (executor.inEventLoop()) { _writeGoAway(errorCode, lastStreamId, debugData); } else { executor.execute(() -> { _writeGoAway(errorCode, lastStreamId, debugData); }); } }