@Override public boolean trySuccess(T result) { return promise.trySuccess(result); }
@Override public boolean trySuccess(T result) { return promise.trySuccess(result); }
@Override public List<Runnable> shutdownNow() { List<Runnable> tasks = super.shutdownNow(); terminationFuture.trySuccess(null); return tasks; }
@Override public void shutdown() { super.shutdown(); terminationFuture.trySuccess(null); }
@Override public List<Runnable> shutdownNow() { List<Runnable> tasks = super.shutdownNow(); terminationFuture.trySuccess(null); return tasks; }
@Override public void shutdown() { super.shutdown(); terminationFuture.trySuccess(null); }
@Override public void operationComplete(Future<Object> future) throws Exception { // Inefficient, but works. if (isTerminated()) { terminationFuture.trySuccess(null); } } };
private boolean tryPromise() { return (cause == null) ? aggregatePromise.trySuccess(null) : aggregatePromise.tryFailure(cause); }
@Override public void operationComplete(Future<Object> future) throws Exception { // Inefficient, but works. if (isTerminated()) { terminationFuture.trySuccess(null); } } };
static <T> void trySuccess(Promise<T> promise, T result) { if (!promise.trySuccess(result)) { logger.warn("Failed to notify success ({}) to a promise: {}", result, promise); } }
private void notifyConnect(ChannelFuture future, Promise<Channel> promise) { if (future.isSuccess()) { Channel channel = future.channel(); if (!promise.trySuccess(channel)) { // Promise was completed in the meantime (like cancelled), just release the channel again release(channel); } } else { promise.tryFailure(future.cause()); } }
private void notifyConnect(ChannelFuture future, Promise<Channel> promise) { if (future.isSuccess()) { Channel channel = future.channel(); if (!promise.trySuccess(channel)) { // Promise was completed in the meantime (like cancelled), just release the channel again release(channel); } } else { promise.tryFailure(future.cause()); } }
private static <T> void transferResult(Future<T> src, Promise<T> dst) { if (src.isSuccess()) { dst.trySuccess(src.getNow()); } else { dst.tryFailure(src.cause()); } }
@Override public boolean onStatus(PubSubType type, CharSequence channel) { if (name.equals(channel) && this.type.equals(type)) { promise.trySuccess(null); } return true; }
@Override public boolean onStatus(PubSubType type, CharSequence channel) { if (name.equals(channel) && this.type.equals(type)) { promise.trySuccess(null); } return true; }
private void setSuccess(AddressedEnvelope<? extends DnsResponse, InetSocketAddress> envelope) { Promise<AddressedEnvelope<DnsResponse, InetSocketAddress>> promise = this.promise; @SuppressWarnings("unchecked") AddressedEnvelope<DnsResponse, InetSocketAddress> castResponse = (AddressedEnvelope<DnsResponse, InetSocketAddress>) envelope.retain(); if (!promise.trySuccess(castResponse)) { // We failed to notify the promise as it was failed before, thus we need to release the envelope envelope.release(); } }
@Override @Deprecated public void shutdown() { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdown(); } for (EventLoop l: idleChildren) { l.shutdown(); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } }
/** * Try to mark the {@link Promise} as success and log if {@code logger} is not {@code null} in case this fails. */ public static <V> void trySuccess(Promise<? super V> p, V result, InternalLogger logger) { if (!p.trySuccess(result) && logger != null) { Throwable err = p.cause(); if (err == null) { logger.warn("Failed to mark a promise as success because it has succeeded already: {}", p); } else { logger.warn( "Failed to mark a promise as success because it has failed already: {}, unnotified cause:", p, err); } } }
public static <X> void cascadeTo(Future<X> completedFuture, Promise<? super X> promise) { if (completedFuture.isSuccess()) { if (!promise.trySuccess(completedFuture.getNow())) { logger.warn("Failed to mark a promise as success because it is done already: {}", promise); } } else if (completedFuture.isCancelled()) { if (!promise.cancel(false)) { logger.warn("Failed to cancel a promise because it is done already: {}", promise); } } else { if (!promise.tryFailure(completedFuture.cause())) { logger.warn("Failed to mark a promise as failure because it's done already: {}", promise, completedFuture.cause()); } } } }
@Override public Future<?> shutdownGracefully(long quietPeriod, long timeout, TimeUnit unit) { shuttingDown = true; for (EventLoop l: activeChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } for (EventLoop l: idleChildren) { l.shutdownGracefully(quietPeriod, timeout, unit); } // Notify the future if there was no children. if (isTerminated()) { terminationFuture.trySuccess(null); } return terminationFuture(); }