本文整理了Java中io.netty.util.concurrent.Promise.trySuccess()
方法的一些代码示例,展示了Promise.trySuccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Promise.trySuccess()
方法的具体详情如下:
包路径:io.netty.util.concurrent.Promise
类名称:Promise
方法名:trySuccess
[英]Marks this future as a success and notifies all listeners.
[中]将此未来标记为成功,并通知所有听众。
代码示例来源:origin: redisson/redisson
@Override
public boolean trySuccess(T result) {
return promise.trySuccess(result);
}
代码示例来源:origin: redisson/redisson
@Override
public boolean trySuccess(T result) {
return promise.trySuccess(result);
}
代码示例来源:origin: netty/netty
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = super.shutdownNow();
terminationFuture.trySuccess(null);
return tasks;
}
代码示例来源:origin: netty/netty
@Override
public void shutdown() {
super.shutdown();
terminationFuture.trySuccess(null);
}
代码示例来源:origin: redisson/redisson
@Override
public List<Runnable> shutdownNow() {
List<Runnable> tasks = super.shutdownNow();
terminationFuture.trySuccess(null);
return tasks;
}
代码示例来源:origin: redisson/redisson
@Override
public void shutdown() {
super.shutdown();
terminationFuture.trySuccess(null);
}
代码示例来源:origin: netty/netty
@Override
public void operationComplete(Future<Object> future) throws Exception {
// Inefficient, but works.
if (isTerminated()) {
terminationFuture.trySuccess(null);
}
}
};
代码示例来源:origin: netty/netty
private boolean tryPromise() {
return (cause == null) ? aggregatePromise.trySuccess(null) : aggregatePromise.tryFailure(cause);
}
代码示例来源:origin: redisson/redisson
@Override
public void operationComplete(Future<Object> future) throws Exception {
// Inefficient, but works.
if (isTerminated()) {
terminationFuture.trySuccess(null);
}
}
};
代码示例来源:origin: redisson/redisson
static <T> void trySuccess(Promise<T> promise, T result) {
if (!promise.trySuccess(result)) {
logger.warn("Failed to notify success ({}) to a promise: {}", result, promise);
}
}
代码示例来源:origin: netty/netty
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());
}
}
代码示例来源:origin: redisson/redisson
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());
}
}
代码示例来源:origin: redisson/redisson
private static <T> void transferResult(Future<T> src, Promise<T> dst) {
if (src.isSuccess()) {
dst.trySuccess(src.getNow());
} else {
dst.tryFailure(src.cause());
}
}
代码示例来源:origin: redisson/redisson
@Override
public boolean onStatus(PubSubType type, CharSequence channel) {
if (name.equals(channel) && this.type.equals(type)) {
promise.trySuccess(null);
}
return true;
}
代码示例来源:origin: redisson/redisson
@Override
public boolean onStatus(PubSubType type, CharSequence channel) {
if (name.equals(channel) && this.type.equals(type)) {
promise.trySuccess(null);
}
return true;
}
代码示例来源:origin: redisson/redisson
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();
}
}
代码示例来源:origin: netty/netty
@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);
}
}
代码示例来源:origin: netty/netty
/**
* 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);
}
}
}
代码示例来源:origin: netty/netty
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());
}
}
}
}
代码示例来源:origin: netty/netty
@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();
}
内容来源于网络,如有侵权,请联系作者删除!