|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.atlassian.util.concurrent.SettableFuture<T>
@ThreadSafe public class SettableFuture<T>
SettableFuture
is a Future
implementation where the
responsibility for producing the result is external to the future instance,
unlike FutureTask
where the future holds the operation (a
Callable
or Runnable
instance) and the first thread that
calls FutureTask.run()
executes the operation.
This is useful in situations where all the inputs may not be available at construction time.
Constructor Summary | |
---|---|
SettableFuture()
|
Method Summary | |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
|
T |
get()
|
T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
|
boolean |
isCancelled()
|
boolean |
isDone()
|
SettableFuture<T> |
set(T value)
Set the value returned by get() and get(long, TimeUnit) |
SettableFuture<T> |
setException(java.lang.Throwable throwable)
Set the exception thrown as the causal exception of an ExecutionException by get() and get(long, TimeUnit) |
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 SettableFuture<T> set(T value)
get()
and get(long, TimeUnit)
Note that this can only be done once unless the value of the second set equals the first value otherwise an exception will be thrown. It also cannot be set if this future has been cancelled or an exception has been set.
value
- the value to be set.public SettableFuture<T> setException(java.lang.Throwable throwable)
get()
and get(long, TimeUnit)
Note that this can only be done once unless the value of the second
setException(Throwable)
equals the first value otherwise an
exception will be thrown (as most exceptions do not implement equals this
effectively means the same reference). It also cannot be set if this
future has been cancelled or a a value has been set.
value
- the value to be set.public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public T 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<T>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public boolean isDone()
isDone
in interface java.util.concurrent.Future<T>
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<T>
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<T>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |