Represents a thread-safe single-assignment, multi-read variable with delayed initialization. Each instance of DataflowVariable can be read repeatedly any time using the 'val' property and assigned once in its lifetime using the '<<' operator. Reads preceding assignment will be blocked until the value is assigned. For actors and Dataflow Operators the asynchronous non-blocking variants of the getValAsync() methods can be used. They register the request to read a value and will send a message to the actor or operator once the value is available.
- Type of values to bind with the DataflowVariableModifiers | Name | Description |
---|---|---|
private PGroup |
group |
|
private java.util.concurrent.atomic.AtomicBoolean |
initializationStarted |
|
private groovy.lang.Closure<T> |
initializer |
Fields inherited from class | Fields |
---|---|
class DataflowVariable |
serialVersionUID |
class DataflowExpression |
ATTACHMENT, A_DATAFLOW_VARIABLE_CAN_ONLY_BE_ASSIGNED_ONCE_ONLY_RE_ASSIGNMENTS_TO_AN_EQUAL_VALUE_ARE_ALLOWED, CANNOT_FIRE_BIND_ERRORS_THE_THREAD_HAS_BEEN_INTERRUPTED, RESULT, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, dummyWaitingThread, error, eventManager, metaClass, serialVersionUID, state, stateUpdater, value, waiting, waitingUpdater |
class WithSerialId |
serialHandle, serialVersionUID |
Constructor and description |
---|
LazyDataflowVariable
(groovy.lang.Closure<T> initializer) Creates a new unbound Lazy Dataflow Variable |
LazyDataflowVariable
(PGroup group, groovy.lang.Closure<T> initializer) Creates a new unbound Lazy Dataflow Variable with specific a PGroup to use for running the initializer |
Type | Name and description |
---|---|
java.lang.Throwable |
getError() Returns the error bound to the promise |
T |
getVal() |
T |
getVal(long timeout, java.util.concurrent.TimeUnit units) |
void |
getValAsync(MessageStream callback) |
void |
getValAsync(java.lang.Object attachment, MessageStream callback) |
private void |
initialize() |
boolean |
isError() Checks if the promise is bound to an error |
Promise<V> |
then(groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler) Schedule closure to be executed after data became available. |
Promise<V> |
then(Pool pool, groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler) Schedule closure to be executed after data becomes available. |
Promise<V> |
then(PGroup group, groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler) Schedule closure to be executed after data becomes available. |
void |
touch() |
Creates a new unbound Lazy Dataflow Variable
Creates a new unbound Lazy Dataflow Variable with specific a PGroup to use for running the initializer
Returns the error bound to the promise
Checks if the promise is bound to an error
Schedule closure to be executed after data became available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled
closure
- closure to execute when data becomes available. The closure should take at most one argument.errorHandler
- closure to execute when an error (instance of Throwable) gets bound. The closure should take at most one argument.Schedule closure to be executed after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
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.errorHandler
- closure to execute when an error (instance of Throwable) gets bound. The closure should take at most one argument.Schedule closure to be executed after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
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.errorHandler
- closure to execute when an error (instance of Throwable) gets bound. The closure should take at most one argument.Copyright © 2008–2014 Václav Pech. All Rights Reserved.