T - the output type of a successful processpublic class SettablePartialFuture<T> extends AbstractPartialFuture<T> implements SettablePartial<T>
PartialFuture that can be fulfilled via the SettablePartial
interface.
SettablePartialFuture has a default Executor that is used when a
SettablePartialFuture is created without passing this parameter, which runs
callback functions immediately on the stack when the future is fulfilled.ReadyPartialFuture| Constructor and Description |
|---|
SettablePartialFuture()
Construct a
SettableFuture with the default Executor |
SettablePartialFuture(Executor executor)
Construct a
SettableFuture with a specified Executor |
| Modifier and Type | Method and Description |
|---|---|
void |
blockInterruptibly()
Blocks until this
Future is set to either a value or an error. |
void |
blockUntilReady()
Blocks until this
Future is set to either a value or an error. |
void |
cancel()
Cancels this asynchronous operation.
|
Throwable |
getError()
Gets the error from a
Future if it has been set to this state. |
T |
getIfDone()
Gets the value from this
Future. |
boolean |
isDone()
Gets the readiness of this
Future. |
boolean |
isError()
Tests if this
Future is set to an error |
boolean |
isSet()
Returns
true if this Settable has been set to a value or error. |
boolean |
onCancelled(Runnable r)
Register code to be called if this operation is cancelled.
|
void |
onCancelledCancel(Cancellable c)
Link an operation to cancel in the event that this
Settable is cancelled. |
void |
set(T value)
Set this
Settable to a value. |
void |
setError(Error error)
Set this
Settable to an error. |
void |
setError(Exception error)
Set this
Settable to an error. |
void |
setError(RuntimeException error)
Set this
Settable to an error. |
dispose, flatMap, get, getInterruptibly, map, onReady, onReadyAlready, rescue, rescuepublic SettablePartialFuture()
SettableFuture with the default Executorpublic SettablePartialFuture(Executor executor)
SettableFuture with a specified Executorexecutor - the Executor with which to execute callbackspublic void set(T value)
SettableSettable to a value. This will invoke callbacks, and unblock
all Threads waiting on associated Futures. A Settable
can be set only once and this call
will throw an exception if this object is already set to a value or error. It
is not, however, an error to call this if the operation has been cancelled.
If the task has been cancelled, this call will have no effect.public void setError(Error error)
SettableSettable to an error. This call will invoke callbacks, and unblock
all Threads waiting on associated Futures. A Settable
can be set only once and this call will
throw an exception if this object is already set to a value or error. It
is not, however, an error to call this method if the operation has been cancelled.
If the task has been cancelled, this call will have no effect.public void setError(RuntimeException error)
SettableSettable to an error. This call will invoke callbacks, and unblock
all Threads waiting on associated Futures. A Settable
can be set only once and this call will
throw an exception if this object is already set to a value or error. It
is not, however, an error to call this method if the operation has been cancelled.
If the task has been cancelled, this call will have no effect.public void setError(Exception error)
SettablePartialSettable to an error. This call will invoke callbacks, and unblock
all Threads waiting on associated Futures. A Settable
can be set only once and this call will
throw an exception if this object is already set to a value or error. It
is not, however, an error to call this method if the operation has been cancelled.
If the task has been cancelled, this call will have no effect.setError in interface SettablePartial<T>error - the error encountered in the course of this processpublic void cancel()
PartialFutureFuture is
ready, subsequent attempts to access its value will throw.
Cancelling a Future which is already set has no effect.
Cancelling a Future should not be assumed to eliminate the affects
of launching the operation. Many asynchronous operations start work on remote
machines -- this work will generally not be stopped if the local Future
is cancelled.cancel in interface Cancellablecancel in interface PartialFuture<T>public boolean isSet()
Settabletrue if this Settable has been set to a value or error.public boolean onCancelled(Runnable r)
SettableSettables can
be cancelled by calls to PartialFuture.cancel() on associated Futures.
If this Settable is already set, the
callback will not be registered and this call will return false. If this
call returns true the registered callback is guaranteed to be called if
the associated Future is cancelled.onCancelled in interface Settable<T>r - routine to execute if cancelled.true if the callback was registered, false otherwise.public void onCancelledCancel(Cancellable c)
SettableSettable is cancelled.
This is a convenience method (for more complicated calls to
Settable.onCancelled(Runnable)) with possible internal optimizations.onCancelledCancel in interface Settable<T>c - the operation to cancelpublic T getIfDone() throws Exception
AbstractPartialFutureFuture. It must be in the ready and non-error
state. This is a non-blocking call. If this Future is set to
an error get() throws this error.Future has been set.FDBException - if the value is either unset, or has been set to an
error.Exceptionpublic void blockUntilReady()
PartialFutureFuture is set to either a value or an error.
When this function returns without an error, PartialFuture.isDone() will return
true.
blockUntilReady in interface PartialFuture<T>public void blockInterruptibly()
throws InterruptedException
PartialFutureFuture is set to either a value or an error.
When this function returns without an error, PartialFuture.isDone() will return
true.
blockInterruptibly in interface PartialFuture<T>InterruptedException - if the blocked thread is interruptedpublic boolean isDone()
PartialFutureFuture. A Future is ready
if the value has been set or an error has been set.isDone in interface PartialFuture<T>true if the Future is set to a value or errorpublic boolean isError()
PartialFutureFuture is set to an errorisError in interface PartialFuture<T>true if in error state, false otherwisepublic Throwable getError()
PartialFutureFuture if it has been set to this state. If
this Future is not yet set, or has not been set to an error, throws
an exception. Although this method returns a Throwable, the set of
possible types is more limited. A PartialFuture is limited to be set in
an error state to an Exception (or a subclass thereof) or an unchecked
Error.getError in interface PartialFuture<T>Future