ListenableFuture whose result can be set by a set(Object), setException(Throwable) or setFuture(ListenableFuture) call. It can also, like any
other Future, be cancelled.
SettableFuture is the recommended ListenableFuture implementation when your
task cannot be implemented with ListeningExecutorService, the various Futures
utility methods, or ListenableFutureTask. Those APIs have less opportunity for developer
error. If your needs are more complex than SettableFuture supports, use AbstractFuture, which offers an extensible version of the API.
ValueFuture)
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static <V extends @Nullable Object> SettableFuture | |
| public boolean | set(V
the value to be used as the result value)Overrides com. Future unless this Future has already been cancelled or
set (including set asynchronously).
|
| public boolean | setException(Throwable
the exception to be used as the failed result throwable)Overrides com. Future unless this Future has already been
cancelled or set (including set asynchronously).
|
| public boolean | setFuture(ListenableFuture<? extends V>
the future to delegate to future)Overrides com. Future to match the supplied input Future once the
supplied Future is done, unless this Future has already been cancelled or set
(including "set asynchronously," defined below).
|
| SettableFuture | back to summary |
|---|---|
| private SettableFuture() | |
| create | back to summary |
|---|---|
| public static <V extends @Nullable Object> SettableFuture Creates a new | |
| set | back to summary |
|---|---|
| public boolean set(V value) Overrides com. Doc from com. Sets the result of this Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
| |
| setException | back to summary |
|---|---|
| public boolean setException(Throwable throwable) Overrides com. Doc from com. Sets the failed result of this Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
| |
| setFuture | back to summary |
|---|---|
| public boolean setFuture(ListenableFuture<? extends V> future) Overrides com. Doc from com. Sets the result of this If the supplied future is done when this method is called and the call
is accepted, then this future is guaranteed to have been completed with the supplied future by
the time this method returns. If the supplied future is not done and the call is accepted, then
the future will be set asynchronously. Note that such a result, though not yet known,
cannot be overridden by a call to a If the call Note that, even if the supplied future is cancelled and it causes this future to complete,
it will never trigger interruption behavior. In particular, it will not cause this future to
invoke the Beware of completing a future while holding a lock. Its listeners may do slow work or acquire other locks, risking deadlocks.
| |