@Override public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { return executor.awaitTermination(timeout, unit); }
final void remove() { EventExecutor executor = executor(); if (executor.inEventLoop()) { remove0(); } else { executor.execute(new Runnable() { @Override public void run() { remove0(); } }); } }
@Override public <T> List<java.util.concurrent.Future<T>> invokeAll( Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException { return next().invokeAll(tasks, timeout, unit); }
@Override public void windowUpdateRatio(float ratio) { assert ctx == null || ctx.executor().inEventLoop(); streamWindowUpdateRatio = ratio; }
if (!success) { for (int j = 0; j < i; j ++) { children[j].shutdownGracefully(); EventExecutor e = children[j]; try { while (!e.isTerminated()) { e.awaitTermination(Integer.MAX_VALUE, TimeUnit.SECONDS); e.terminationFuture().addListener(terminationListener);
@Override public final Future<List<T>> resolveAll(SocketAddress address) { if (!isSupported(checkNotNull(address, "address"))) { // Address type not supported by the resolver return executor().newFailedFuture(new UnsupportedAddressTypeException()); } if (isResolved(address)) { // Resolved already; no need to perform a lookup @SuppressWarnings("unchecked") final T cast = (T) address; return executor.newSucceededFuture(Collections.singletonList(cast)); } try { @SuppressWarnings("unchecked") final T cast = (T) address; final Promise<List<T>> promise = executor().newPromise(); doResolveAll(cast, promise); return promise; } catch (Exception e) { return executor().newFailedFuture(e); } }
private void acquire0(final Promise<Channel> promise) { assert executor.inEventLoop(); Promise<Channel> p = executor.newPromise(); AcquireListener l = new AcquireListener(promise); l.acquired(); task.timeoutFuture = executor.schedule(timeoutTask, acquireTimeoutNanos, TimeUnit.NANOSECONDS);
@Override public Future<T> resolve(String inetHost) { return resolve(inetHost, executor.<T>newPromise()); }
@Override public void close() { executor.execute(new Runnable() { @Override public void run() { if (!closed) { closed = true; for (;;) { AcquireTask task = pendingAcquireQueue.poll(); if (task == null) { break; } ScheduledFuture<?> f = task.timeoutFuture; if (f != null) { f.cancel(false); } task.promise.setFailure(new ClosedChannelException()); } acquiredChannelCount = 0; pendingAcquireCount = 0; FixedChannelPool.super.close(); } } }); } }
if (executor.isShuttingDown()) { throw new IllegalStateException("executor not accepting a task"); executor.terminationFuture().addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception {
@Override public void run() { assert executor().inEventLoop(); try { if (periodNanos == 0) { if (!executor().isShutdown()) { long p = periodNanos; if (p > 0) {
@Override public boolean isShutdown() { for (EventExecutor l: children) { if (!l.isShutdown()) { return false; } } return true; }
@Override public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return next().invokeAny(tasks, timeout, unit); }
@Override public boolean isTerminated() { return executor.isTerminated(); }
@Override public boolean isShuttingDown() { for (EventExecutor l: children) { if (!l.isShuttingDown()) { return false; } } return true; }
/** * Returns the number of pending write operations. */ public int size() { assert ctx.executor().inEventLoop(); return size; }
@Override public final Future<T> resolve(SocketAddress address) { if (!isSupported(checkNotNull(address, "address"))) { // Address type not supported by the resolver return executor().newFailedFuture(new UnsupportedAddressTypeException()); } if (isResolved(address)) { // Resolved already; no need to perform a lookup @SuppressWarnings("unchecked") final T cast = (T) address; return executor.newSucceededFuture(cast); } try { @SuppressWarnings("unchecked") final T cast = (T) address; final Promise<T> promise = executor().newPromise(); doResolve(cast, promise); return promise; } catch (Exception e) { return executor().newFailedFuture(e); } }
public AcquireTask(Promise<Channel> promise) { super(promise); // We need to create a new promise as we need to ensure the AcquireListener runs in the correct // EventLoop. this.promise = executor.<Channel>newPromise().addListener(this); } }
@Override public void execute(Runnable command) { next().execute(command); } }
@Override public boolean isShuttingDown() { return executor.isShutdown(); }