public interface Promise<T>
Modifier and Type | Method and Description |
---|---|
T |
get()
Retrieves the value of the variable, blocking until a value is available
|
T |
get(long timeout,
java.util.concurrent.TimeUnit units)
Retrieves the value of the variable, blocking up to given timeout, if the value has not been assigned yet.
|
T |
getVal()
Reads the current value of the channel.
|
T |
getVal(long timeout,
java.util.concurrent.TimeUnit units)
Reads the current value of the channel.
|
void |
getValAsync(MessageStream callback)
Asynchronously retrieves the value from the channel.
|
void |
getValAsync(java.lang.Object attachment,
MessageStream callback)
Asynchronously retrieves the value from the channel.
|
boolean |
isBound()
Check if value has been set already for this expression
|
<V> Promise<V> |
rightShift(groovy.lang.Closure<V> closure)
Schedule closure to be executed after data became available.
|
<V> Promise<V> |
then(groovy.lang.Closure<V> closure)
Schedule closure to be executed after data became available.
|
<V> Promise<V> |
then(PGroup group,
groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes available.
|
<V> Promise<V> |
then(Pool pool,
groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes available.
|
<V> void |
whenBound(groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes available.
|
void |
whenBound(MessageStream stream)
Send the bound data to provided stream when it becomes available
|
<V> void |
whenBound(PGroup group,
groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes available.
|
<V> void |
whenBound(Pool pool,
groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes available.
|
T get() throws java.lang.Throwable
java.lang.Throwable
- If the stored value is an exception instance it gets re-thrownT get(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.Throwable
timeout
- The timeout valueunits
- Units for the timeoutjava.lang.Throwable
- If the stored value is an exception instance it gets re-thrownvoid getValAsync(MessageStream callback)
callback
- An actor to send the bound value to.void getValAsync(java.lang.Object attachment, MessageStream callback)
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.T getVal() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the channel to be boundT getVal(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
timeout
- The timeout valueunits
- Units for the timeoutjava.lang.InterruptedException
- If the current thread gets interrupted while waiting for the channel to be bound<V> Promise<V> rightShift(groovy.lang.Closure<V> closure)
closure
- closure to execute when data becomes available. The closure should take at most one argument.<V> void whenBound(groovy.lang.Closure<V> closure)
closure
- closure to execute when data becomes available. The closure should take at most one argument.<V> void whenBound(Pool pool, groovy.lang.Closure<V> closure)
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.<V> void whenBound(PGroup group, groovy.lang.Closure<V> closure)
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.void whenBound(MessageStream stream)
stream
- stream where to send result<V> Promise<V> then(groovy.lang.Closure<V> closure)
closure
- closure to execute when data becomes available. The closure should take at most one argument.<V> Promise<V> then(Pool pool, groovy.lang.Closure<V> closure)
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.<V> Promise<V> then(PGroup group, groovy.lang.Closure<V> closure)
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.boolean isBound()