T
- Type of values to bind with the DataflowVariablepublic final class LazyDataflowVariable<T> extends DataflowVariable<T>
DataflowVariable.RemoteDataflowVariable<T>
DataflowExpression.BindDataflow<T>
Modifier and Type | Field and Description |
---|---|
private PGroup |
group |
private java.util.concurrent.atomic.AtomicBoolean |
initializationStarted |
private groovy.lang.Closure<T> |
initializer |
error, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, state, value
serialHandle
Constructor and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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
|
<V> Promise<V> |
then(groovy.lang.Closure<V> closure,
groovy.lang.Closure<V> errorHandler)
Schedule closure to be executed after data became available.
|
<V> Promise<V> |
then(PGroup group,
groovy.lang.Closure<V> closure,
groovy.lang.Closure<V> errorHandler)
Schedule closure to be executed after data becomes available.
|
<V> Promise<V> |
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
|
get, get, getRemoteClass, leftShift, leftShift, shouldThrowTimeout
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, bind, bindError, bindSafely, bindUnique, chainWith, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, doBindImpl, doBindRemote, evaluate, filter, filter, filter, filter, filter, filter, getBindErrorManager, getEventManager, getMetaClass, getProperty, into, into, into, into, into, into, invokeMethod, isBound, join, join, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, 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
createRemoteHandle, getOrCreateSerialHandle, writeReplace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, chainWith, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, filter, filter, filter, filter, filter, filter, getEventManager, 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
poll, wheneverBound, wheneverBound
bind
isBound, join, join, rightShift, then, then, then, thenForkAndJoin, thenForkAndJoin, thenForkAndJoin, whenBound, whenBound, whenBound, whenBound
private final groovy.lang.Closure<T> initializer
private final java.util.concurrent.atomic.AtomicBoolean initializationStarted
private final PGroup group
public LazyDataflowVariable(groovy.lang.Closure<T> initializer)
private void initialize()
public void touch()
Promise
public final boolean isError()
public final java.lang.Throwable getError()
public 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 timeoutjava.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.