@java.lang.SuppressWarnings({"AccessingNonPublicFieldOfAnotherObject", "UnqualifiedStaticUsage"}) public class DataflowVariable extends DataflowExpression
Represents a thread-safe single-assignment, multi-read variable. 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 static long |
serialVersionUID |
Fields inherited from class | Fields |
---|---|
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 |
---|
DataflowVariable
() Creates a new unbound Dataflow Variable |
Type | Name and description |
---|---|
private DataflowWriteChannel<T> |
bindDFV(DataflowReadChannel<T> ref) |
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. |
java.lang.Throwable |
getError() Returns the error bound to the promise |
java.lang.Class<RemoteDataflowVariable> |
getRemoteClass() |
boolean |
isError() Checks if the promise is bound to an error |
DataflowWriteChannel<T> |
leftShift(T value) Assigns a value to the variable. |
DataflowWriteChannel<T> |
leftShift(DataflowReadChannel<T> ref) Assigns a value from one DataflowVariable instance to this variable. |
boolean |
shouldThrowTimeout() |
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() |
Retrieves the value of the variable, blocking until a value is available
Retrieves the value of the variable, blocking up to given timeout, if the value has not been assigned yet.
timeout
- The timeout valueunits
- Units for the timeoutReturns the error bound to the promise
Checks if the promise is bound to an error
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable
value
- The value to assignAssigns a value from one DataflowVariable instance to this variable. Can only be invoked once on each instance of DataflowVariable
ref
- The DataflowVariable instance the value of which to bindSchedule 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.