public class Val<V>
extends java.lang.Object
implements java.util.concurrent.Future<V>
| Constructor and Description |
|---|
Val() |
Val(FiberScheduler scheduler,
SuspendableCallable<V> f)
Creates a
Val whose value will be the one returned by the given SuspendableCallable, which will be spawned
into a new fiber, scheduled by the given FiberScheduler. |
Val(SuspendableCallable<V> f)
Creates a
Val whose value will be the one returned by the given SuspendableCallable, which will be spawned
into a new fiber. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
Throws
UnsupportedOperationException. |
V |
get()
Returns the delayed value, blocking until it has been set.
|
V |
get(long timeout,
java.util.concurrent.TimeUnit unit)
Returns the delayed value, blocking until it has been set, but no longer than the given timeout.
|
V |
get(Timeout timeout) |
protected SimpleConditionSynchronizer |
getSync() |
boolean |
isCancelled() |
boolean |
isDone() |
void |
set(V value)
Sets the value.
|
void |
setException(java.lang.Throwable t)
Sets an exception that will be thrown by
get, wrapped by RuntimeExecutionException. |
public Val(SuspendableCallable<V> f)
Val whose value will be the one returned by the given SuspendableCallable, which will be spawned
into a new fiber.
f - The function that will compute this Val's value in a newly spawned fiberpublic Val(FiberScheduler scheduler, SuspendableCallable<V> f)
Val whose value will be the one returned by the given SuspendableCallable, which will be spawned
into a new fiber, scheduled by the given FiberScheduler.
scheduler - the scheduler in which the new fiber will be spawned.f - The function that will compute this Val's value in a newly spawned fiberpublic Val()
public final void set(V value)
IllegalStateException. However, you should not rely on this behavior,
as the implementation is free to silently ignore additional attempts to set the value.value - the valuejava.lang.IllegalStateException - if the value has already been set.public final void setException(java.lang.Throwable t)
get, wrapped by RuntimeExecutionException.Throwable - t the exceptionjava.lang.IllegalStateException - if the value has already been set.public boolean isDone()
isDone in interface java.util.concurrent.Future<V>protected SimpleConditionSynchronizer getSync()
@Suspendable public V get() throws java.lang.InterruptedException
get in interface java.util.concurrent.Future<V>java.lang.InterruptedException@Suspendable public V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<V>timeout - The maximum duration to block waiting for the value to be set.unit - The time unit of the timeout value.java.util.concurrent.TimeoutException - if the timeout expires before the value is set.java.lang.InterruptedException@Suspendable public V get(Timeout timeout) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedExceptionjava.util.concurrent.TimeoutExceptionpublic boolean cancel(boolean mayInterruptIfRunning)
UnsupportedOperationException.cancel in interface java.util.concurrent.Future<V>public boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<V>