|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.levigo.util.concurrent.SettableFuture<V>
V
- the value typepublic class SettableFuture<V>
An implementation of a Future
. Its result may be set via set(Object)
, an error
may be signalized via setError(Throwable)
. It may also be canceled via
cancel(boolean)
.
This class will be superfluous with Java 8 since it provides the class java.util.concurrent.CompletableFuture with a lot more features.
Constructor Summary | |
---|---|
SettableFuture()
|
Method Summary | |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
|
V |
get()
|
V |
get(long timeout,
TimeUnit unit)
|
boolean |
isCancelled()
|
boolean |
isDone()
|
V |
poll()
Gets the future result, but returns immediately if no result is available yet |
void |
set(V result)
Set the result of this Future |
void |
setError(Throwable error)
Signalize an error which will cause an ExecutionException on subsequent calls of the
get methods |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SettableFuture()
Method Detail |
---|
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface Future<V>
public boolean isCancelled()
isCancelled
in interface Future<V>
public boolean isDone()
isDone
in interface Future<V>
public V poll() throws ExecutionException
null
if no result is available yet
ExecutionException
- if an error was signalized via setError(Throwable)
CancellationException
- if the future was cancelled via cancel(boolean)
public V get() throws InterruptedException, ExecutionException
get
in interface Future<V>
InterruptedException
ExecutionException
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<V>
InterruptedException
ExecutionException
TimeoutException
public void set(V result)
Future
result
-
IllegalStateException
- if a result or an error has already been setpublic void setError(Throwable error)
ExecutionException
on subsequent calls of the
get methods
error
- the error
IllegalStateException
- if a result or an error has already been set
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |