public class Eventual<Result extends Failable,V> extends java.lang.Object implements PrecipiceFuture<Result,V>, PrecipicePromise<Result,V>, ExecutionContext
| Constructor and Description |
|---|
Eventual() |
Eventual(Completable<Result,V> completable) |
Eventual(long permitCount) |
Eventual(long permitCount,
long startNanos) |
Eventual(long permitCount,
long startNanos,
Completable<Result,V> completable) |
| Modifier and Type | Method and Description |
|---|---|
void |
await()
Block until the completion of the future.
|
void |
await(long duration,
java.util.concurrent.TimeUnit unit)
Block until the completion of the future or until the time duration is exceeded.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
boolean |
complete(Result result,
V value)
Completes this context successfully with the result.
|
boolean |
completeExceptionally(Result result,
java.lang.Throwable exception)
Completes this context with an exception.
|
PrecipiceFuture<Result,V> |
future()
Returns a future containing the result of this promise
|
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
java.lang.Throwable |
getError()
Return the exception that might have occurred during a failed execution.
|
Result |
getResult()
Return the result of the execution.
|
V |
getValue()
Return the value of a successful execution.
|
void |
internalOnComplete(PrecipiceFunction<Result,ExecutionContext> fn) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
onError(PrecipiceFunction<Result,java.lang.Throwable> fn)
Attaches a callback to be executed if the future is not completed successfully.
|
void |
onSuccess(PrecipiceFunction<Result,V> fn)
Attaches a callback to be executed if the future is completed successfully.
|
long |
permitCount()
Returns the number of guard rail permits that this task required.
|
ResultView<Result,V> |
resultView()
Returns a view of the result of of this completable.
|
void |
setCancellable(Cancellable cancellable) |
long |
startNanos()
Returns the time that the guard rail approved the execution of this task.
|
public Eventual()
public Eventual(long permitCount)
public Eventual(long permitCount,
long startNanos)
public Eventual(Completable<Result,V> completable)
public Eventual(long permitCount,
long startNanos,
Completable<Result,V> completable)
public boolean complete(Result result, V value)
Completablecomplete in interface Completable<Result extends Failable,V>result - of the computationvalue - of the computationpublic boolean completeExceptionally(Result result, java.lang.Throwable exception)
CompletablecompleteExceptionally in interface Completable<Result extends Failable,V>result - of the computationexception - of the computationpublic ResultView<Result,V> resultView()
CompletableresultView in interface Completable<Result extends Failable,V>public PrecipiceFuture<Result,V> future()
PrecipicePromisefuture in interface PrecipicePromise<Result extends Failable,V>public V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<V>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<V>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic boolean isDone()
isDone in interface java.util.concurrent.Future<V>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<V>public boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<V>public void await()
throws java.lang.InterruptedException
PrecipiceFutureawait in interface PrecipiceFuture<Result extends Failable,V>java.lang.InterruptedExceptionpublic void await(long duration,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
PrecipiceFutureawait in interface PrecipiceFuture<Result extends Failable,V>duration - the maximum duration to waitunit - the unit of the duration argumentjava.lang.InterruptedExceptionpublic V getValue()
ResultViewgetValue in interface ResultView<Result extends Failable,V>public java.lang.Throwable getError()
ResultViewgetError in interface ResultView<Result extends Failable,V>public void onSuccess(PrecipiceFunction<Result,V> fn)
PrecipiceFutureonSuccess in interface PrecipiceFuture<Result extends Failable,V>fn - function to be executedpublic void onError(PrecipiceFunction<Result,java.lang.Throwable> fn)
PrecipiceFutureonError in interface PrecipiceFuture<Result extends Failable,V>fn - function to be executedpublic Result getResult()
ResultViewgetResult in interface ResultView<Result extends Failable,V>public long startNanos()
ExecutionContextstartNanos in interface ExecutionContextpublic long permitCount()
ExecutionContextpermitCount in interface ExecutionContextpublic void setCancellable(Cancellable cancellable)
public void internalOnComplete(PrecipiceFunction<Result,ExecutionContext> fn)
Copyright © 2014 Tim Brooks. All Rights Reserved.