|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.gpars.serial.WithSerialId
groovyx.gpars.dataflow.expression.DataflowExpression<T>
groovyx.gpars.dataflow.DataflowVariable<T>
groovyx.gpars.dataflow.LazyDataflowVariable<T>
T
- Type of values to bind with the DataflowVariablepublic final class LazyDataflowVariable<T>
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class groovyx.gpars.dataflow.DataflowVariable |
---|
DataflowVariable.RemoteDataflowVariable<T> |
Nested classes/interfaces inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
DataflowExpression.BindDataflow<T> |
Field Summary | |
---|---|
private PGroup |
group
|
private java.util.concurrent.atomic.AtomicBoolean |
initializationStarted
|
private groovy.lang.Closure<T> |
initializer
|
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 | |
---|---|
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 |
Method Summary | ||
---|---|---|
java.lang.Throwable |
getError()
Returns the error bound to the promise |
|
T |
getVal()
Reads the value of the variable. |
|
T |
getVal(long timeout,
java.util.concurrent.TimeUnit units)
Reads the value of the variable. |
|
void |
getValAsync(MessageStream callback)
Asynchronously retrieves the value of the variable. |
|
void |
getValAsync(java.lang.Object attachment,
MessageStream callback)
Used by Dataflow operators. |
|
private void |
initialize()
|
|
boolean |
isError()
Checks if the promise is bound to an error |
|
|
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. |
|
void |
touch()
May be used by lazy implementations to warm up |
Methods inherited from class groovyx.gpars.dataflow.DataflowVariable |
---|
get, get, getRemoteClass, leftShift, leftShift, shouldThrowTimeout |
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, 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, 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 |
Methods inherited from interface groovyx.gpars.dataflow.SelectableChannel |
---|
poll, 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 final groovy.lang.Closure<T> initializer
private final java.util.concurrent.atomic.AtomicBoolean initializationStarted
private final PGroup group
Constructor Detail |
---|
public LazyDataflowVariable(groovy.lang.Closure<T> initializer)
public LazyDataflowVariable(PGroup group, groovy.lang.Closure<T> initializer)
Method Detail |
---|
private void initialize()
public void touch()
Promise
touch
in interface Promise<T>
touch
in class DataflowVariable<T>
public final boolean isError()
isError
in interface Promise<T>
isError
in class DataflowVariable<T>
public final java.lang.Throwable getError()
getError
in interface Promise<T>
getError
in class DataflowVariable<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>
then
in class DataflowVariable<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>
then
in class DataflowVariable<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>
then
in class DataflowVariable<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 T getVal() throws java.lang.InterruptedException
DataflowExpression
getVal
in interface DataflowReadChannel<T>
getVal
in class DataflowExpression<T>
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic T getVal(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
DataflowExpression
getVal
in interface DataflowReadChannel<T>
getVal
in class DataflowExpression<T>
timeout
- The timeout valueunits
- Units for the timeout
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic void getValAsync(MessageStream callback)
DataflowExpression
getValAsync
in interface DataflowReadChannel<T>
getValAsync
in class DataflowExpression<T>
callback
- An actor to send the bound value to.public void getValAsync(java.lang.Object attachment, MessageStream callback)
DataflowExpression
getValAsync
in interface DataflowReadChannel<T>
getValAsync
in class DataflowExpression<T>
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.
|
Copyright © 2008–2013 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |