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.boolean
await(long timeoutMillis)
Waits for this future to be completed within the specified time limit.boolean
await(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.boolean
awaitUninterruptibly(long timeoutMillis)
Waits for this future to be completed within the specified time limit without interruption.boolean
awaitUninterruptibly(long timeout, TimeUnit unit)
Waits for this future to be completed within the specified time limit without interruption.boolean
cancel(boolean mayInterruptIfRunning)
Throwable
cause()
Returns the cause of the failed I/O operation if the I/O operation has failed.CompletionStage<T>
exceptionally(Function<Throwable,? extends T> fn)
T
get()
T
get(long timeout, TimeUnit unit)
RPromise<T>
getInnerPromise()
T
getNow()
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)
boolean
hasListeners()
boolean
isCancelled()
boolean
isDone()
boolean
isSuccess()
Returnstrue
if and only if the I/O operation was completed successfully.T
join()
Returns the result value when complete, or throws an (unchecked) exception if completed exceptionally.void
onComplete(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)
boolean
setUncancellable()
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()
boolean
tryFailure(Throwable cause)
Marks this future as a failure and notifies all listeners.boolean
trySuccess(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:RFuture
Returns 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:RFuture
Returnstrue
if and only if the I/O operation was completed successfully.
-
trySuccess
public boolean trySuccess(T result)
Description copied from interface:RPromise
Marks this future as a success and notifies all listeners.- Specified by:
trySuccess
in interfaceRPromise<T>
- Parameters:
result
- object- Returns:
true
if and only if successfully marked this future as a success. Otherwisefalse
because this future is already marked as either a success or a failure.
-
cause
public Throwable cause()
Description copied from interface:RFuture
Returns the cause of the failed I/O operation if the I/O operation has failed.
-
getNow
public T getNow()
Description copied from interface:RFuture
Return the result without blocking. If the future is not done yet this will returnnull
. As it is possible that anull
value 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 returnednull
value.
-
tryFailure
public boolean tryFailure(Throwable cause)
Description copied from interface:RPromise
Marks this future as a failure and notifies all listeners.- Specified by:
tryFailure
in interfaceRPromise<T>
- Parameters:
cause
- object- Returns:
true
if and only if successfully marked this future as a failure. Otherwisefalse
because this future is already marked as either a success or a failure.
-
await
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
Description copied from interface:RFuture
Waits for this future to be completed within the specified time limit.- Specified by:
await
in interfaceRFuture<T>
- Parameters:
timeout
- - wait timeoutunit
- - time unit- Returns:
true
if 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:RPromise
Make this future impossible to cancel.- Specified by:
setUncancellable
in interfaceRPromise<T>
- Returns:
true
if and only if successfully marked this future as uncancellable or it is already done without being cancelled.false
if this future has been cancelled already.
-
await
public boolean await(long timeoutMillis) throws InterruptedException
Description copied from interface:RFuture
Waits for this future to be completed within the specified time limit.- Specified by:
await
in interfaceRFuture<T>
- Parameters:
timeoutMillis
- - timeout value- Returns:
true
if 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:RFuture
Waits for this future to be completed.
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
awaitUninterruptibly
public RPromise<T> awaitUninterruptibly()
Description copied from interface:RFuture
Waits for this future to be completed without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceRFuture<T>
- Specified by:
awaitUninterruptibly
in interfaceRPromise<T>
- Returns:
- Future object
-
sync
public RPromise<T> sync() throws InterruptedException
Description copied from interface:RFuture
Waits 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:RFuture
Waits for this future until it is done, and rethrows the cause of the failure if this future failed.- Specified by:
syncUninterruptibly
in interfaceRFuture<T>
- Specified by:
syncUninterruptibly
in interfaceRPromise<T>
- Returns:
- Future object
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interfaceFuture<T>
-
get
public T get() throws InterruptedException, ExecutionException
- Specified by:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, TimeUnit unit)
Description copied from interface:RFuture
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceRFuture<T>
- Parameters:
timeout
- - timeout valueunit
- - timeout unit value- Returns:
true
if 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:
get
in interfaceFuture<T>
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
thenApply
public <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
- Specified by:
thenApply
in interfaceCompletionStage<T>
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)
Description copied from interface:RFuture
Waits for this future to be completed within the specified time limit without interruption. This method catches anInterruptedException
and discards it silently.- Specified by:
awaitUninterruptibly
in interfaceRFuture<T>
- Parameters:
timeoutMillis
- - timeout value- Returns:
true
if 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:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenApplyAsync
public <U> CompletionStage<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
- Specified by:
thenApplyAsync
in interfaceCompletionStage<T>
-
thenAccept
public CompletionStage<Void> thenAccept(Consumer<? super T> action)
- Specified by:
thenAccept
in interfaceCompletionStage<T>
-
thenAcceptAsync
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action)
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
hasListeners
public boolean hasListeners()
- Specified by:
hasListeners
in interfaceRPromise<T>
-
thenAcceptAsync
public CompletionStage<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
- Specified by:
thenAcceptAsync
in interfaceCompletionStage<T>
-
thenRun
public CompletionStage<Void> thenRun(Runnable action)
- Specified by:
thenRun
in interfaceCompletionStage<T>
-
thenRunAsync
public CompletionStage<Void> thenRunAsync(Runnable action)
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenRunAsync
public CompletionStage<Void> thenRunAsync(Runnable action, Executor executor)
- Specified by:
thenRunAsync
in interfaceCompletionStage<T>
-
thenCombine
public <U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombine
in interfaceCompletionStage<T>
-
thenCombineAsync
public <U,V> CompletionStage<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
- Specified by:
thenCombineAsync
in 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:
thenCombineAsync
in interfaceCompletionStage<T>
-
thenAcceptBoth
public <U> CompletionStage<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBoth
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
- Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
thenAcceptBothAsync
public <U> CompletionStage<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
- Specified by:
thenAcceptBothAsync
in interfaceCompletionStage<T>
-
runAfterBoth
public CompletionStage<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBoth
in interfaceCompletionStage<T>
-
runAfterBothAsync
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
runAfterBothAsync
public CompletionStage<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterBothAsync
in interfaceCompletionStage<T>
-
applyToEither
public <U> CompletionStage<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEither
in interfaceCompletionStage<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
- Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
applyToEitherAsync
public <U> CompletionStage<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
- Specified by:
applyToEitherAsync
in interfaceCompletionStage<T>
-
acceptEither
public CompletionStage<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEither
in interfaceCompletionStage<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
- Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
acceptEitherAsync
public CompletionStage<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
- Specified by:
acceptEitherAsync
in interfaceCompletionStage<T>
-
runAfterEither
public CompletionStage<Void> runAfterEither(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEither
in interfaceCompletionStage<T>
-
runAfterEitherAsync
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
runAfterEitherAsync
public CompletionStage<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
- Specified by:
runAfterEitherAsync
in interfaceCompletionStage<T>
-
thenCompose
public <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenCompose
in interfaceCompletionStage<T>
-
thenComposeAsync
public <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
thenComposeAsync
public <U> CompletionStage<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
- Specified by:
thenComposeAsync
in interfaceCompletionStage<T>
-
exceptionally
public CompletionStage<T> exceptionally(Function<Throwable,? extends T> fn)
- Specified by:
exceptionally
in interfaceCompletionStage<T>
-
whenComplete
public CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenComplete
in interfaceCompletionStage<T>
-
whenCompleteAsync
public CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
whenCompleteAsync
public CompletionStage<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
- Specified by:
whenCompleteAsync
in interfaceCompletionStage<T>
-
handle
public <U> CompletionStage<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handle
in interfaceCompletionStage<T>
-
handleAsync
public <U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
- Specified by:
handleAsync
in interfaceCompletionStage<T>
-
handleAsync
public <U> CompletionStage<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
- Specified by:
handleAsync
in interfaceCompletionStage<T>
-
toCompletableFuture
public CompletableFuture<T> toCompletableFuture()
- Specified by:
toCompletableFuture
in interfaceCompletionStage<T>
-
onComplete
public void onComplete(BiConsumer<? super T,? super Throwable> action)
- Specified by:
onComplete
in interfaceRFuture<T>
-
-