@Override public void deregister(ChannelPromise promise) { EmbeddedUnsafe.this.deregister(promise); runPendingTasks(); }
@Override public void bind(SocketAddress localAddress, ChannelPromise promise) { EmbeddedUnsafe.this.bind(localAddress, promise); runPendingTasks(); }
@Override public void beginRead() { EmbeddedUnsafe.this.beginRead(); runPendingTasks(); }
/** * Flushes the outbound of this {@link Channel}. This method is conceptually equivalent to {@link #flush()}. * * @see #flushInbound() */ public EmbeddedChannel flushOutbound() { if (checkOpen(true)) { flushOutbound0(); } checkException(voidPromise()); return this; }
private void flushOutbound0() { // We need to call runPendingTasks first as a ChannelOutboundHandler may used eventloop.execute(...) to // delay the write on the next eventloop run. runPendingTasks(); flush(); }
@Override public void closeForcibly() { EmbeddedUnsafe.this.closeForcibly(); runPendingTasks(); }
@Override public void register(EventLoop eventLoop, ChannelPromise promise) { EmbeddedUnsafe.this.register(eventLoop, promise); runPendingTasks(); }
@Override public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) { EmbeddedUnsafe.this.connect(remoteAddress, localAddress, promise); runPendingTasks(); }
@Override public void disconnect(ChannelPromise promise) { EmbeddedUnsafe.this.disconnect(promise); runPendingTasks(); }
@Override public void close(ChannelPromise promise) { EmbeddedUnsafe.this.close(promise); runPendingTasks(); }
@Override public void write(Object msg, ChannelPromise promise) { EmbeddedUnsafe.this.write(msg, promise); runPendingTasks(); }
private void finishPendingTasks(boolean cancel) { runPendingTasks(); if (cancel) { // Cancel all scheduled tasks that are left. loop.cancelScheduledTasks(); } }
@Override public void flush() { EmbeddedUnsafe.this.flush(); runPendingTasks(); }
/** * Run all pending scheduled tasks in the {@link EventLoop} for this {@link Channel} and return the * {@code nanoseconds} when the next scheduled task is ready to run. If no other task was scheduled it will return * {@code -1}. */ public long runScheduledPendingTasks() { try { return loop.runScheduledTasks(); } catch (Exception e) { recordException(e); return loop.nextScheduledTask(); } }
/** * Mark this {@link Channel} as finished and release all pending message in the inbound and outbound buffer. * Any further try to write data to it will fail. * * @return bufferReadable returns {@code true} if any of the used buffers has something left to read */ public boolean finishAndReleaseAll() { return finish(true); }
/** * Flushes the inbound of this {@link Channel}. This method is conceptually equivalent to {@link #flush()}. * * @see #flushOutbound() */ public EmbeddedChannel flushInbound() { flushInbound(true, voidPromise()); return this; }
/** * Ensure the {@link Channel} is open and if not throw an exception. */ protected final void ensureOpen() { if (!checkOpen(true)) { checkException(); } }
/** * Release all buffered inbound messages and return {@code true} if any were in the inbound buffer, {@code false} * otherwise. */ public boolean releaseInbound() { return releaseAll(inboundMessages); }
@Override public ChannelOutboundBuffer outboundBuffer() { return EmbeddedUnsafe.this.outboundBuffer(); } };
@Override public void connect(SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) { safeSetSuccess(promise); } }