org.codehaus.gpars

groovyx.gpars.dataflow
[Java] Class LazyDataflowVariable

java.lang.Object
  groovyx.gpars.serial.WithSerialId
      groovyx.gpars.dataflow.expression.DataflowExpression
          groovyx.gpars.dataflow.DataflowVariable
              groovyx.gpars.dataflow.LazyDataflowVariable

@java.lang.SuppressWarnings*/
public final class LazyDataflowVariable
extends DataflowVariable

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.

Parameters:
- Type of values to bind with the DataflowVariable
Authors:
Vaclav Pech Date: April 4, 2013


Field Summary
private PGroup group

private java.util.concurrent.atomic.AtomicBoolean initializationStarted

private groovy.lang.Closure initializer

 
Fields inherited from class DataflowVariable
serialVersionUID
 
Fields inherited from 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, value, waiting
 
Fields inherited from class WithSerialId
serialHandle, serialVersionUID
 
Constructor Summary
LazyDataflowVariable(groovy.lang.Closure initializer)

LazyDataflowVariable(PGroup group, groovy.lang.Closure initializer)

 
Method Summary
java.lang.Throwable getError()

Schedule closure to be executed after data became available.

java.lang.Object getVal()

java.lang.Object getVal(long timeout, java.util.concurrent.TimeUnit units)

void getValAsync(MessageStream callback)

void getValAsync(java.lang.Object attachment, MessageStream callback)

private void initialize()

boolean isError()

Returns the error bound to the promise

Promise then(groovy.lang.Closure closure, groovy.lang.Closure errorHandler)

Promise then(Pool pool, groovy.lang.Closure closure, groovy.lang.Closure errorHandler)

Promise then(PGroup group, groovy.lang.Closure closure, groovy.lang.Closure errorHandler)

void touch()

Checks if the promise is bound to an error

 
Methods inherited from class DataflowVariable
bindDFV, get, get, getError, getRemoteClass, isError, leftShift, leftShift, shouldThrowTimeout, then, then, then, touch
 
Methods inherited from class DataflowExpression
DataflowExpression, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, bind, bindError, bindSafely, bindUnique, chainWith, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, createEventManager, doBind, doBindImpl, doBindRemote, doThenForkAndJoin, evaluate, filter, filter, filter, filter, filter, filter, fireBindError, fireBindError, fireOnMessage, getBindErrorManager, getEventManager, getMetaClass, getProperty, getVal, getVal, getValAsync, getValAsync, handleInterruption, into, into, into, into, into, into, invokeMethod, isBound, join, join, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, notifyRemote, or, or, poll, rightShift, scheduleCallback, separate, separate, separate, separate, separate, separate, setMetaClass, setProperty, split, split, split, split, split, split, split, split, split, split, split, split, subscribe, subscribe, tap, tap, tap, tap, tap, tap, then, then, then, thenForkAndJoin, thenForkAndJoin, thenForkAndJoin, toString, transform, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound
 
Methods inherited from class WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 

Field Detail

group

private final PGroup group


initializationStarted

private final java.util.concurrent.atomic.AtomicBoolean initializationStarted


initializer

private final groovy.lang.Closure initializer


 
Constructor Detail

LazyDataflowVariable

public LazyDataflowVariable(groovy.lang.Closure initializer)


LazyDataflowVariable

public LazyDataflowVariable(PGroup group, groovy.lang.Closure initializer)


 
Method Detail

getError

@java.lang.Override
public final java.lang.Throwable getError()
Schedule 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
Parameters:
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.
Returns:
A promise for the results of the supplied closure. This allows for chaining of then() method calls.


getVal

@java.lang.Overridesuper.getValAsync(callback);
public java.lang.Object getVal()


getVal

@java.lang.Overridesuper.getValAsync(attachment, callback);
public java.lang.Object getVal(long timeout, java.util.concurrent.TimeUnit units)


getValAsync

@java.lang.Override
public void getValAsync(MessageStream callback)


getValAsync

@java.lang.Override
public void getValAsync(java.lang.Object attachment, MessageStream callback)


initialize

private void initialize()


isError

@java.lang.Overridereturn super.getError();
public final boolean isError()
Returns the error bound to the promise
throws:
IllegalStateException If not bound or not bound to an error
Returns:
The error


then

@java.lang.Override*/
public final Promise then(groovy.lang.Closure closure, groovy.lang.Closure errorHandler)


then

@java.lang.Override*/
public final Promise then(Pool pool, groovy.lang.Closure closure, groovy.lang.Closure errorHandler)


then

@java.lang.Overridereturn super.getVal(timeout, units);
public final Promise then(PGroup group, groovy.lang.Closure closure, groovy.lang.Closure errorHandler)


touch

@java.lang.Override}
public void touch()
Checks if the promise is bound to an error
Returns:
True, if an error has been bound


 

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