groovyx.gpars.dataflow
Class DataFlowVariable<T>
java.lang.Object
groovyx.gpars.serial.WithSerialId
groovyx.gpars.dataflow.DataFlowExpression<T>
groovyx.gpars.dataflow.DataFlowVariable<T>
- Type Parameters:
T
- Type of values to bind with the DataFlowVariable
- All Implemented Interfaces:
- groovy.lang.GroovyObject, DataFlowChannel<T>, DataFlowReadChannel<T>, DataFlowWriteChannel<T>, java.io.Serializable
- Direct Known Subclasses:
- DataFlowVariable.RemoteDataFlowVariable
public class DataFlowVariable<T>
- extends DataFlowExpression<T>
- implements DataFlowChannel<T>
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.
- Author:
- Vaclav Pech, Alex Tkachman
Date: Jun 4, 2009
- See Also:
- Serialized Form
Methods inherited from class groovyx.gpars.dataflow.DataFlowExpression |
bind, bindSafely, bindUnique, doBindRemote, evaluate, getMetaClass, getProperty, getVal, getVal, getValAsync, getValAsync, invokeMethod, isBound, join, join, poll, rightShift, setMetaClass, setProperty, subscribe, subscribe, toString, transform, whenBound, whenBound, wheneverBound, wheneverBound |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface groovyx.gpars.dataflow.DataFlowReadChannel |
getVal, getVal, getValAsync, getValAsync, isBound, poll, rightShift, whenBound, whenBound, wheneverBound, wheneverBound |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
DataFlowVariable
public DataFlowVariable()
- Creates a new unbound Dataflow Variable
leftShift
public DataFlowWriteChannel<T> leftShift(T value)
- Assigns a value to the variable. Can only be invoked once on each instance of DataFlowVariable
- Specified by:
leftShift
in interface DataFlowWriteChannel<T>
- Parameters:
value
- The value to assign
- Returns:
- The current channel instance
leftShift
public DataFlowWriteChannel<T> leftShift(DataFlowReadChannel<T> ref)
- Assigns a value from one DataFlowVariable instance to this variable.
Can only be invoked once on each instance of DataFlowVariable
- Specified by:
leftShift
in interface DataFlowWriteChannel<T>
- Parameters:
ref
- The DataFlowVariable instance the value of which to bind
- Returns:
- The current channel instance
getRemoteClass
public java.lang.Class<DataFlowVariable.RemoteDataFlowVariable> getRemoteClass()
- Description copied from class:
WithSerialId
- Class of remote object to be created
- Overrides:
getRemoteClass
in class WithSerialId
- Returns:
- Throws UnsupportedOperationException