Package io.hekate.util
Class HekateFuture<T,F extends HekateFuture<T,F>>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- io.hekate.util.HekateFuture<T,F>
-
- Type Parameters:
T
- Result type.F
- Subclass type.
- All Implemented Interfaces:
CompletionStage<T>
,Future<T>
- Direct Known Subclasses:
CoordinationFuture
,InitializationFuture
,JoinFuture
,LeaderFuture
,LeaveFuture
,MessagingFuture
,TerminateFuture
public abstract class HekateFuture<T,F extends HekateFuture<T,F>> extends CompletableFuture<T>
Base class for asynchronous operation results.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask
-
-
Constructor Summary
Constructors Constructor Description HekateFuture()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description F
fork()
Returns a new future instance who's lifecycle depends on this instance but not vice versa.boolean
isSuccess()
protected abstract F
newInstance()
Constructs new future instance of this class.T
sync()
Same asCompletableFuture.get()
but throws unchecked exceptions.T
sync(long timeout, TimeUnit unit)
Same asCompletableFuture.get(long, TimeUnit)
but throws unchecked exceptions.-
Methods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
-
-
-
Method Detail
-
newInstance
protected abstract F newInstance()
Constructs new future instance of this class.This method is used by
fork()
to construct a new future objects.- Returns:
- New instance.
-
sync
public T sync()
Same asCompletableFuture.get()
but throws unchecked exceptions.- Returns:
- Result value.
- Throws:
HekateInterruptedException
- If thread got interrupted.HekateExecutionException
- If this future completed exceptionally.CancellationException
- If this future was cancelled.
-
sync
public T sync(long timeout, TimeUnit unit)
Same asCompletableFuture.get(long, TimeUnit)
but throws unchecked exceptions.- Parameters:
timeout
- Maximum time to wait.unit
- Time unit of the timeout argument.- Returns:
- Result value.
- Throws:
HekateInterruptedException
- If thread got interrupted.HekateTimeoutException
- If the wait timed out.HekateExecutionException
- If this future completed exceptionally.CancellationException
- If this future was cancelled.
-
isSuccess
public boolean isSuccess()
- Returns:
true
if this future completed successfully.
-
fork
public F fork()
Returns a new future instance who's lifecycle depends on this instance but not vice versa.If this instance gets completed (either normally or with an error) then forked instance will be completed too. Completing forked instance has no impact on this instance.
- Returns:
- Fork of this instance.
-
-