|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.serial.WithSerialId groovyx.gpars.dataflow.expression.DataflowExpression<T> groovyx.gpars.dataflow.DataflowVariable<T>
T
- Type of values to bind with the DataflowVariablepublic class DataflowVariable<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.
Nested Class Summary | |
---|---|
static class |
DataflowVariable.RemoteDataflowVariable<T>
|
Nested classes/interfaces inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
DataflowExpression.BindDataflow<T> |
Field Summary | |
---|---|
private static long |
serialVersionUID
|
Fields inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
error, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, state, value |
Fields inherited from class groovyx.gpars.serial.WithSerialId |
---|
serialHandle |
Constructor Summary | |
---|---|
DataflowVariable()
Creates a new unbound Dataflow Variable |
Method Summary | ||
---|---|---|
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<DataflowVariable.RemoteDataflowVariable> |
getRemoteClass()
Class of remote object to be created |
|
boolean |
isError()
Checks if the promise is bound to an error |
|
DataflowWriteChannel<T> |
leftShift(DataflowReadChannel<T> ref)
Assigns a value from one DataflowVariable instance to this variable. |
|
DataflowWriteChannel<T> |
leftShift(T value)
Assigns a value to the variable. |
|
(package private) boolean |
shouldThrowTimeout()
|
|
|
then(groovy.lang.Closure<V> closure,
groovy.lang.Closure<V> errorHandler)
Schedule closure to be executed after data became available. |
|
|
then(PGroup group,
groovy.lang.Closure<V> closure,
groovy.lang.Closure<V> errorHandler)
Schedule closure to be executed after data becomes available. |
|
|
then(Pool pool,
groovy.lang.Closure<V> closure,
groovy.lang.Closure<V> errorHandler)
Schedule closure to be executed after data becomes available. |
Methods inherited from class groovyx.gpars.serial.WithSerialId |
---|
createRemoteHandle, getOrCreateSerialHandle, writeReplace |
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 |
---|
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, filter, filter, filter, filter, filter, filter, getEventManager, getVal, getVal, getValAsync, getValAsync, chainWith, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, into, into, into, into, into, into, isBound, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, or, or, poll, rightShift, separate, separate, separate, separate, separate, separate, split, split, split, split, split, split, split, split, split, split, split, split, tap, tap, tap, tap, tap, tap, then, then, then, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound |
Methods inherited from interface groovyx.gpars.dataflow.DataflowWriteChannel |
---|
bind |
Methods inherited from interface groovyx.gpars.dataflow.Promise |
---|
isBound, join, join, rightShift, then, then, then, whenBound, whenBound, whenBound, whenBound |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
public DataflowVariable()
Method Detail |
---|
public DataflowWriteChannel<T> leftShift(T value)
leftShift
in interface DataflowWriteChannel<T>
value
- The value to assign
public DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref)
leftShift
in interface DataflowWriteChannel<T>
ref
- The DataflowVariable instance the value of which to bind
private DataflowWriteChannel<T> bindDFV(DataflowReadChannel<T> ref)
public T get() throws java.lang.Throwable
get
in interface Promise<T>
java.lang.Throwable
- If the stored value is an exception instance it gets re-thrownpublic final T get(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.Throwable
get
in interface Promise<T>
timeout
- The timeout valueunits
- Units for the timeout
java.lang.Throwable
- If the stored value is an exception instance it gets re-thrownboolean shouldThrowTimeout()
public final boolean isError()
isError
in interface Promise<T>
public final java.lang.Throwable getError()
getError
in interface Promise<T>
java.lang.IllegalStateException
- If not bound or not bound to an errorpublic final <V> Promise<V> then(groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler)
then
in interface Promise<T>
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.
public final <V> Promise<V> then(Pool pool, groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler)
then
in interface Promise<T>
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.
public final <V> Promise<V> then(PGroup group, groovy.lang.Closure<V> closure, groovy.lang.Closure<V> errorHandler)
then
in interface Promise<T>
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.
public java.lang.Class<DataflowVariable.RemoteDataflowVariable> getRemoteClass()
WithSerialId
getRemoteClass
in class WithSerialId
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |