List of usage examples for io.netty.util.concurrent DefaultPromise setSuccess
@Override
public Promise<V> setSuccess(V result)
From source file:io.lettuce.core.resource.Futures.java
License:Apache License
/** * Create a promise that emits a {@code Boolean} value on completion of the {@code future} * * @param future the future./*from w w w.j av a 2 s. c om*/ * @return Promise emitting a {@code Boolean} value. {@literal true} if the {@code future} completed successfully, otherwise * the cause wil be transported. */ static Promise<Boolean> toBooleanPromise(Future<?> future) { DefaultPromise<Boolean> result = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); if (future.isDone() || future.isCancelled()) { if (future.isSuccess()) { result.setSuccess(true); } else { result.setFailure(future.cause()); } return result; } future.addListener((GenericFutureListener<Future<Object>>) f -> { if (f.isSuccess()) { result.setSuccess(true); } else { result.setFailure(f.cause()); } }); return result; }
From source file:io.lettuce.core.resource.FuturesTest.java
License:Apache License
@Test public void regularUse() { final DefaultPromise<Boolean> target = new DefaultPromise<>(GlobalEventExecutor.INSTANCE); Futures.PromiseAggregator<Boolean, Promise<Boolean>> sut = new Futures.PromiseAggregator<>(target); sut.expectMore(1);/*from w w w . j av a 2 s. c o m*/ sut.arm(); DefaultPromise<Boolean> part = new DefaultPromise<Boolean>(GlobalEventExecutor.INSTANCE); sut.add(part); assertThat(target.isDone()).isFalse(); part.setSuccess(true); Wait.untilTrue(target::isDone).waitOrTimeout(); assertThat(target.isDone()).isTrue(); }
From source file:org.springframework.data.redis.connection.lettuce.TestEventLoopGroupProvider.java
License:Apache License
@Override public Promise<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {//from www . java 2s . c o m DefaultPromise<Boolean> result = new DefaultPromise<Boolean>(ImmediateEventExecutor.INSTANCE); result.setSuccess(true); return result; }