org.codehaus.gpars

groovyx.gpars.dataflow
[Java] Class DataflowVariable

java.lang.Object
  groovyx.gpars.serial.WithSerialId
      groovyx.gpars.dataflow.DataflowExpression
          groovyx.gpars.dataflow.DataflowVariable
All Implemented Interfaces:
DataflowChannel, Promise

@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.

Parameters:
- Type of values to bind with the DataflowVariable
Authors:
Vaclav Pech, Alex Tkachman Date: Jun 4, 2009


Nested Class Summary
static class DataflowVariable.RemoteDataflowVariable

 
Field Summary
private static long serialVersionUID

 
Fields inherited from class DataflowExpression
ATTACHMENT, RESULT, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, dummyWaitingThread, metaClass, serialVersionUID, state, stateUpdater, value, waiting, waitingUpdater
 
Fields inherited from class WithSerialId
serialHandle, serialVersionUID
 
Constructor Summary
DataflowVariable()

Creates a new unbound Dataflow Variable

 
Method Summary
private DataflowWriteChannel bindDFV(DataflowReadChannel 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.Class getRemoteClass()

DataflowWriteChannel leftShift(T value)

Assigns a value to the variable.

DataflowWriteChannel leftShift(DataflowReadChannel ref)

Assigns a value from one DataflowVariable instance to this variable.

 
Methods inherited from class DataflowExpression
DataflowExpression, bind, bindSafely, bindUnique, doBind, doBindImpl, doBindRemote, evaluate, getMetaClass, getProperty, getVal, getVal, getValAsync, getValAsync, handleInterruption, invokeMethod, isBound, join, join, notifyRemote, poll, rightShift, scheduleCallback, setMetaClass, setProperty, subscribe, subscribe, toString, transform, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound
 
Methods inherited from class WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

serialVersionUID

private static final long serialVersionUID


 
Constructor Detail

DataflowVariable

public DataflowVariable()
Creates a new unbound Dataflow Variable


 
Method Detail

bindDFV

private DataflowWriteChannel bindDFV(DataflowReadChannel ref)


get

@SuppressWarnings({"ProhibitedExceptionDeclared"})
public T get()
Retrieves the value of the variable, blocking until a value is available
throws:
Throwable If the stored value is an exception instance it gets re-thrown
Returns:
The value stored in the variable


get

@SuppressWarnings({"ProhibitedExceptionDeclared"})
public 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.
throws:
Throwable If the stored value is an exception instance it gets re-thrown
Parameters:
timeout - The timeout value
units - Units for the timeout
Returns:
The value stored in the variable


getRemoteClass

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public java.lang.Class getRemoteClass()


leftShift

@Override
public DataflowWriteChannel leftShift(T value)
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable
Parameters:
value - The value to assign


leftShift

@Override
public DataflowWriteChannel leftShift(DataflowReadChannel ref)
Assigns a value from one DataflowVariable instance to this variable. Can only be invoked once on each instance of DataflowVariable
Parameters:
ref - The DataflowVariable instance the value of which to bind


 

Copyright © 2008–2010 Václav Pech. All Rights Reserved.