public class FutureValue<V>
extends java.lang.Object
implements java.util.concurrent.Future<V>, java.io.Serializable
Constructor and Description |
---|
FutureValue()
Creates a future that will be waiting for its result.
|
FutureValue(V value)
Creates a future that is immediately set with its result value.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_done()
Protected method invoked when this task transitions to state isDone (whether normally or via cancellation).
|
boolean |
cancel(boolean mayInterruptIfRunning) |
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
set(V v)
Sets the result of this Future to the given value unless this future has already been set or has been cancelled.
|
void |
setException(java.lang.Throwable t)
Causes this future to report an ExecutionException with the given throwable as its cause,
unless this Future has already been set or has been cancelled.
|
java.lang.String |
toString() |
public FutureValue()
public FutureValue(V value)
value
- the future's resultpublic boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<V>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<V>
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<V>
mayInterruptIfRunning
- ignored in this simple value-based implementationpublic V get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<V>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public 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.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public void set(V v)
v
- the valuepublic void setException(java.lang.Throwable t)
t
- the cause of failurepublic java.lang.String toString()
toString
in class java.lang.Object
protected void _done()