public class SimpleSettableFuture<T>
extends java.lang.Object
implements java.util.concurrent.Future<T>
| Constructor and Description |
|---|
SimpleSettableFuture() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
T |
get() |
T |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Wait up to the timeout time for another Thread to set a value on this future.
|
T |
getOrThrow()
Convenience wrapper for
get() that re-throws get()'s Exceptions as RuntimeExceptions. |
T |
getOrThrow(long timeout,
java.util.concurrent.TimeUnit unit)
Convenience wrapper for
get(long, TimeUnit) that re-throws get()'s Exceptions as
RuntimeExceptions. |
boolean |
isCancelled() |
boolean |
isDone() |
void |
set(T result)
Sets the result.
|
void |
setException(java.lang.Exception exception)
Sets the exception.
|
public void set(T result)
get(), they will immediately receive the
value. set or setException must only be called once.public void setException(java.lang.Exception exception)
get(), they will immediately receive
the exception. set or setException must only be called once.public boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<T>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<T>public boolean isDone()
isDone in interface java.util.concurrent.Future<T>public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionpublic T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
NB: For simplicity, we catch and wrap InterruptedException. Do NOT use this class if you are in the 1% of cases where you actually want to handle that.
get in interface java.util.concurrent.Future<T>java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionpublic T getOrThrow()
get() that re-throws get()'s Exceptions as RuntimeExceptions.public T getOrThrow(long timeout, java.util.concurrent.TimeUnit unit)
get(long, TimeUnit) that re-throws get()'s Exceptions as
RuntimeExceptions.