Package oracle.pgx.api
Class PgxFuture<T>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- oracle.pgx.api.PgxFuture<T>
-
- All Implemented Interfaces:
java.util.concurrent.CompletionStage<T>
,java.util.concurrent.Future<T>
public class PgxFuture<T> extends java.util.concurrent.CompletableFuture<T>
A PGX-specific extension ofCompletableFuture
-
-
Constructor Summary
Constructors Constructor Description PgxFuture()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> PgxFuture<java.lang.Void>
allOf(java.util.List<PgxFuture<T>> promises)
boolean
cancel()
PgxFuture<T>
cancelOn(PgxFuture promise)
If given promise completes exceptionally because it was canceled,CompletableFuture.cancel(boolean)
gets called on this promise as well.static <T> PgxFuture<T>
completedFuture(T arg)
PgxFuture<T>
exceptionally(java.util.function.Function<java.lang.Throwable,? extends T> fn)
static <T> PgxFuture<T>
exceptionallyCompletedFuture(java.lang.Throwable throwable)
T
get()
T
get(long timeout, java.util.concurrent.TimeUnit unit)
T
getNow(T valueIfAbsent)
FutureProgress
getProgress()
compute statistics about the progress and estimation to finish a PgxFuture Currently only supported for Graph loading features<U> PgxFuture<U>
handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
boolean
isConsumed()
T
join()
PgxFuture<java.lang.Void>
thenAccept(java.util.function.Consumer<? super T> block)
<U> PgxFuture<U>
thenApply(java.util.function.Function<? super T,? extends U> function)
<U> PgxFuture<U>
thenApplyAsync(java.util.function.Function<? super T,? extends U> function, java.util.concurrent.Executor executor)
<U,V>
PgxFuture<V>thenCombine(java.util.concurrent.CompletableFuture<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends V> function)
PgxFuture<T>
thenComplete(PgxFuture<T> promise)
completes the given promise whenever this completes.PgxFuture<T>
thenComplete(PgxFuture<T> promise, java.lang.Runnable cleanup)
completes the given promise whenever this completes.<U> PgxFuture<U>
thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> function)
<U> PgxFuture<U>
thenReturn(U result)
A future that discards its result and returns the given parameter on completion.-
Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, failedFuture, failedStage, getNumberOfDependents, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
-
-
-
Method Detail
-
completedFuture
public static <T> PgxFuture<T> completedFuture(@Nullable T arg)
-
exceptionallyCompletedFuture
public static <T> PgxFuture<T> exceptionallyCompletedFuture(java.lang.Throwable throwable)
-
thenApply
public <U> PgxFuture<U> thenApply(java.util.function.Function<? super T,? extends U> function)
-
thenApplyAsync
public <U> PgxFuture<U> thenApplyAsync(java.util.function.Function<? super T,? extends U> function, java.util.concurrent.Executor executor)
-
thenCombine
public <U,V> PgxFuture<V> thenCombine(java.util.concurrent.CompletableFuture<? extends U> other, java.util.function.BiFunction<? super T,? super U,? extends V> function)
-
thenReturn
public <U> PgxFuture<U> thenReturn(U result)
A future that discards its result and returns the given parameter on completion.Shortcut for
thenApply(t -> result)
.- Parameters:
result
- the result to return on completion of this future- Returns:
- a future returning the result on completion
-
get
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
-
get
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
-
getNow
public T getNow(T valueIfAbsent)
- Overrides:
getNow
in classjava.util.concurrent.CompletableFuture<T>
-
thenAccept
public PgxFuture<java.lang.Void> thenAccept(java.util.function.Consumer<? super T> block)
-
handle
public <U> PgxFuture<U> handle(java.util.function.BiFunction<? super T,java.lang.Throwable,? extends U> fn)
-
thenCompose
public <U> PgxFuture<U> thenCompose(java.util.function.Function<? super T,? extends java.util.concurrent.CompletionStage<U>> function)
-
exceptionally
public PgxFuture<T> exceptionally(java.util.function.Function<java.lang.Throwable,? extends T> fn)
-
thenComplete
public PgxFuture<T> thenComplete(PgxFuture<T> promise)
completes the given promise whenever this completes.If this completes exceptionally, the given promise is completed exceptionally as well.
- Parameters:
promise
- the promise- Returns:
- the pgx future
-
thenComplete
public PgxFuture<T> thenComplete(PgxFuture<T> promise, java.lang.Runnable cleanup)
completes the given promise whenever this completes.If this completes exceptionally, the given promise is completed exceptionally as well.
- Parameters:
promise
-cleanup
- to be run upon completion (can be null)- Returns:
- the given promise
-
cancel
public boolean cancel()
-
cancelOn
public PgxFuture<T> cancelOn(PgxFuture promise)
If given promise completes exceptionally because it was canceled,CompletableFuture.cancel(boolean)
gets called on this promise as well.- Parameters:
promise
- If given promise completes exceptionally because it was canceled,CompletableFuture.cancel(boolean)
gets called on this promise as well. If given promise completes exceptionally (regardless of the causing exception) and this promise has started or is done, this promise is then rolled back.- Returns:
- this
-
isConsumed
public boolean isConsumed()
-
getProgress
public FutureProgress getProgress()
compute statistics about the progress and estimation to finish a PgxFuture Currently only supported for Graph loading features- Parameters:
future
- a pgx future- Returns:
- progress of the future execution
-
-