Package org.redisson.misc
Class PromiseDelegator<T>
- java.lang.Object
-
- org.redisson.misc.PromiseDelegator<T>
-
- Type Parameters:
T- type
- All Implemented Interfaces:
CompletionStage<T>,Future<T>,RFuture<T>,RPromise<T>
- Direct Known Subclasses:
RedissonExecutorFuture,RedissonScheduledFuture
public class PromiseDelegator<T> extends Object implements RPromise<T>
- Author:
- Nikita Koksharov
-
-
Constructor Summary
Constructors Constructor Description PromiseDelegator(RPromise<T> promise)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)CompletionStage<Void>acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)CompletionStage<Void>acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)<U> CompletionStage<U>applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)<U> CompletionStage<U>applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)<U> CompletionStage<U>applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)RPromise<T>await()Waits for this future to be completed.booleanawait(long timeoutMillis)Waits for this future to be completed within the specified time limit.booleanawait(long timeout, TimeUnit unit)Waits for this future to be completed within the specified time limit.RPromise<T>awaitUninterruptibly()Waits for this future to be completed without interruption.booleanawaitUninterruptibly(long timeoutMillis)Waits for this future to be completed within the specified time limit without interruption.booleanawaitUninterruptibly(long timeout, TimeUnit unit)Waits for this future to be completed within the specified time limit without interruption.booleancancel(boolean mayInterruptIfRunning)Throwablecause()Returns the cause of the failed I/O operation if the I/O operation has failed.CompletionStage<T>exceptionally(Function<Throwable,? extends T> fn)Tget()Tget(long timeout, TimeUnit unit)RPromise<T>getInnerPromise()TgetNow()Return the result without blocking.<U> CompletionStage<U>handle(BiFunction<? super T,Throwable,? extends U> fn)<U> CompletionStage<U>handleAsync(BiFunction<? super T,Throwable,? extends U> fn)<U> CompletionStage<U>handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)booleanhasListeners()booleanisCancelled()booleanisDone()booleanisSuccess()Returnstrueif and only if the I/O operation was completed successfully.Tjoin()Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.voidonComplete(BiConsumer<? super T,? super Throwable> action)CompletionStage<Void>runAfterBoth(CompletionStage<?> other, Runnable action)CompletionStage<Void>runAfterBothAsync(CompletionStage<?> other, Runnable action)CompletionStage<Void>runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)CompletionStage<Void>runAfterEither(CompletionStage<?> other, Runnable action)CompletionStage<Void>runAfterEitherAsync(CompletionStage<?> other, Runnable action)CompletionStage<Void>runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)booleansetUncancellable()Make this future impossible to cancel.RPromise<T>sync()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.RPromise<T>syncUninterruptibly()Waits for this future until it is done, and rethrows the cause of the failure if this future failed.CompletionStage<Void>thenAccept(Consumer<? super T> action)CompletionStage<Void>thenAcceptAsync(Consumer<? super T> action)CompletionStage<Void>thenAcceptAsync(Consumer<? super T> action, Executor executor)<U> CompletionStage<Void>thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)<U> CompletionStage<Void>thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)<U> CompletionStage<Void>thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)<U> CompletionStage<U>thenApply(Function<? super T,? extends U> fn)<U> CompletionStage<U>thenApplyAsync(Function<? super T,? extends U> fn)<U> CompletionStage<U>thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)<U,V>
CompletionStage<V>thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)<U,V>
CompletionStage<V>thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)<U,V>
CompletionStage<V>thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)<U> CompletionStage<U>thenCompose(Function<? super T,? extends CompletionStage<U>> fn)<U> CompletionStage<U>thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)<U> CompletionStage<U>thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)CompletionStage<Void>thenRun(Runnable action)CompletionStage<Void>thenRunAsync(Runnable action)CompletionStage<Void>thenRunAsync(Runnable action, Executor executor)CompletableFuture<T>toCompletableFuture()booleantryFailure(Throwable cause)Marks this future as a failure and notifies all listeners.booleantrySuccess(T result)Marks this future as a success and notifies all listeners.CompletionStage<T>whenComplete(BiConsumer<? super T,? super Throwable> action)CompletionStage<T>whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)CompletionStage<T>whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
-
-
-
Method Detail
-
join
public T join()
Description copied from interface:RFutureReturns the result value when complete, or throws an (unchecked) exception if completed exceptionally. To better conform with the use of common functional forms, if a computation involved in the completion of this CompletableFuture threw an exception.
-
isSuccess
public boolean isSuccess()
Description copied from interface:RFutureReturnstrueif and only if the I/O operation was completed successfully.
-
trySuccess
public boolean trySuccess(T result)
Description copied from interface:RPromiseMarks this future as a success and notifies all listeners.- Specified by:
trySuccessin interfaceRPromise<T>- Parameters:
result- object- Returns:
trueif and only if successfully marked this future as a success. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
cause
public Throwable cause()
Description copied from interface:RFutureReturns the cause of the failed I/O operation if the I/O operation has failed.
-
getNow
public T getNow()
Description copied from interface:RFutureReturn the result without blocking. If the future is not done yet this will returnnull. As it is possible that anullvalue is used to mark the future as successful you also need to check if the future is really done withFuture.isDone()and not relay on the returnednullvalue.
-
tryFailure
public boolean tryFailure(Throwable cause)
Description copied from interface:RPromiseMarks this future as a failure and notifies all listeners.- Specified by:
tryFailurein interfaceRPromise<T>- Parameters:
cause- object- Returns:
trueif and only if successfully marked this future as a failure. Otherwisefalsebecause this future is already marked as either a success or a failure.
-
await
public boolean await(long timeout, TimeUnit unit) throws InterruptedExceptionDescription copied from interface:RFutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceRFuture<T>- Parameters:
timeout- - wait timeoutunit- - time unit- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
setUncancellable
public boolean setUncancellable()
Description copied from interface:RPromiseMake this future impossible to cancel.- Specified by:
setUncancellablein interfaceRPromise<T>- Returns:
trueif and only if successfully marked this future as uncancellable or it is already done without being cancelled.falseif this future has been cancelled already.
-
await
public boolean await(long timeoutMillis) throws InterruptedExceptionDescription copied from interface:RFutureWaits for this future to be completed within the specified time limit.- Specified by:
awaitin interfaceRFuture<T>- Parameters:
timeoutMillis- - timeout value- Returns:
trueif and only if the future was completed within the specified time limit- Throws:
InterruptedException- if the current thread was interrupted
-
await
public RPromise<T> await() throws InterruptedException
Description copied from interface:RFutureWaits for this future to be completed.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
awaitUninterruptibly
public RPromise<T> awaitUninterruptibly()
Description copied from interface:RFutureWaits for this future to be completed without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceRFuture<T>- Specified by:
awaitUninterruptiblyin interfaceRPromise<T>- Returns:
- Future object
-
sync
public RPromise<T> sync() throws InterruptedException
Description copied from interface:RFutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.
-
syncUninterruptibly
public RPromise<T> syncUninterruptibly()
Description copied from interface:RFutureWaits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptiblyin interfaceRFuture<T>- Specified by:
syncUninterruptiblyin interfaceRPromise<T>- Returns:
- Future object
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfaceFuture<T>
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionException
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, TimeUnit unit)Description copied from interface:RFutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceRFuture<T>- Parameters:
timeout- - timeout valueunit- - timeout unit value- Returns:
trueif and only if the future was completed within the specified time limit
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
- Specified by:
getin interfaceFuture<T>- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
thenApply
public <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
- Specified by:
thenApplyin interfaceCompletionStage<T>
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Description copied from interface:RFutureWaits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedExceptionand discards it silently.- Specified by:
awaitUninterruptiblyin interfaceRFuture<T>- Parameters:
timeoutMillis- - timeout value- Returns:
trueif and only if the future was completed within the specified time limit
-
thenApplyAsync
public <U> CompletionStage<U> thenApplyAsync(Function<? super T,? extends U> fn)
- Specified by:
thenApplyAsyncin interfaceCompletionStage<T>
-
thenApplyAsync
public <U> CompletionStage<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
- Specified by:
thenApplyAsyncin interfaceCompletionStage<T>
-
thenAccept
public CompletionStage<Void> thenAccept(Consumer<? super T> action)
- Specified by:
thenAcceptin interfaceCompletionStage<T>
-
thenAcceptAsync
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action)
- Specified by:
thenAcceptAsyncin interfaceCompletionStage<T>
-
hasListeners
public boolean hasListeners()
- Specified by:
hasListenersin interfaceRPromise<T>
-
thenAcceptAsync
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
- Specified by:
thenAcceptAsyncin interfaceCompletionStage<T>
-
thenRun
public CompletionStage<Void> thenRun(Runnable action)
- Specified by:
thenRunin interfaceCompletionStage<T>
-
thenRunAsync
public CompletionStage<Void> thenRunAsync(Runnable action)
- Specified by:
thenRunAsyncin interfaceCompletionStage<T>
-
thenRunAsync
public CompletionStage<Void> thenRunAsync(Runnable action, Executor executor)
- Specified by:
thenRunAsyncin interfaceCompletionStage<T>
-
thenCombine
public <U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombinein interfaceCompletionStage<T>
-
thenCombineAsync
public <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombineAsyncin interfaceCompletionStage<T>
-
thenCombineAsync
public <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
- Specified by:
thenCombineAsyncin interfaceCompletionStage<T>
-
thenAcceptBoth
public <U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBothin interfaceCompletionStage<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBothAsyncin interfaceCompletionStage<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
- Specified by:
thenAcceptBothAsyncin interfaceCompletionStage<T>
-
runAfterBoth
public CompletionStage<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBothin interfaceCompletionStage<T>
-
runAfterBothAsync
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBothAsyncin interfaceCompletionStage<T>
-
runAfterBothAsync
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterBothAsyncin interfaceCompletionStage<T>
-
applyToEither
public <U> CompletionStage<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEitherin interfaceCompletionStage<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEitherAsyncin interfaceCompletionStage<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
- Specified by:
applyToEitherAsyncin interfaceCompletionStage<T>
-
acceptEither
public CompletionStage<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEitherin interfaceCompletionStage<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEitherAsyncin interfaceCompletionStage<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
- Specified by:
acceptEitherAsyncin interfaceCompletionStage<T>
-
runAfterEither
public CompletionStage<Void> runAfterEither(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEitherin interfaceCompletionStage<T>
-
runAfterEitherAsync
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEitherAsyncin interfaceCompletionStage<T>
-
runAfterEitherAsync
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterEitherAsyncin interfaceCompletionStage<T>
-
thenCompose
public <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenComposein interfaceCompletionStage<T>
-
thenComposeAsync
public <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenComposeAsyncin interfaceCompletionStage<T>
-
thenComposeAsync
public <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
- Specified by:
thenComposeAsyncin interfaceCompletionStage<T>
-
exceptionally
public CompletionStage<T> exceptionally(Function<Throwable,? extends T> fn)
- Specified by:
exceptionallyin interfaceCompletionStage<T>
-
whenComplete
public CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenCompletein interfaceCompletionStage<T>
-
whenCompleteAsync
public CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenCompleteAsyncin interfaceCompletionStage<T>
-
whenCompleteAsync
public CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
- Specified by:
whenCompleteAsyncin interfaceCompletionStage<T>
-
handle
public <U> CompletionStage<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handlein interfaceCompletionStage<T>
-
handleAsync
public <U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handleAsyncin interfaceCompletionStage<T>
-
handleAsync
public <U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
- Specified by:
handleAsyncin interfaceCompletionStage<T>
-
toCompletableFuture
public CompletableFuture<T> toCompletableFuture()
- Specified by:
toCompletableFuturein interfaceCompletionStage<T>
-
onComplete
public void onComplete(BiConsumer<? super T,? super Throwable> action)
- Specified by:
onCompletein interfaceRFuture<T>
-
-