groovyx.gpars.dataflow.expression
Class DataflowExpression<T>

java.lang.Object
  extended by groovyx.gpars.serial.WithSerialId
      extended by groovyx.gpars.dataflow.expression.DataflowExpression<T>
All Implemented Interfaces:
groovy.lang.GroovyObject, DataflowReadChannel<T>, java.io.Serializable
Direct Known Subclasses:
DataflowComplexExpression, DataflowExpression.TransformOne, DataflowGetPropertyExpression, DataflowVariable, RemoteDataflowExpression

public abstract class DataflowExpression<T>
extends WithSerialId
implements groovy.lang.GroovyObject, DataflowReadChannel<T>

The base class for all dataflow elements.

Author:
Alex Tkachman, Vaclav Pech
See Also:
Serialized Form

Nested Class Summary
static class DataflowExpression.BindDataflow<T>
          Represents a remote message binding a value to a remoted DataflowExpression
(package private)  class DataflowExpression.DataflowExpressionsCollector
          Listener for availability of data flow expressions we depend on.
private static class DataflowExpression.TransformMany<V>
           
private static class DataflowExpression.TransformOne<V>
           
private static class DataflowExpression.WaitingThread
          A logical representation of a synchronous or asynchronous request to read the value once it is bound.
 
Field Summary
private static java.lang.String ATTACHMENT
           
private static DataflowExpression.WaitingThread dummyWaitingThread
          A request chain terminator
protected  java.lang.Throwable error
           
private  DataflowChannelEventOrchestrator<T> eventManager
           
private  groovy.lang.MetaClass metaClass
          The current metaclass
private static java.lang.String RESULT
           
protected static int S_INITIALIZED
           
protected static int S_INITIALIZING
           
protected static int S_NOT_INITIALIZED
          Possible states
private static long serialVersionUID
           
protected  java.util.concurrent.atomic.AtomicInteger state
          Holds the current state of the variable
protected  T value
          Holds the actual value.
private  java.util.concurrent.atomic.AtomicReference<DataflowExpression.WaitingThread> waiting
          Points to the head of the chain of requests waiting for a value to be bound
 
Fields inherited from class groovyx.gpars.serial.WithSerialId
serialHandle
 
Constructor Summary
protected DataflowExpression()
          Creates a new unbound Dataflow Expression
 
Method Summary
 void binaryChoice(DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void binaryChoice(java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void binaryChoice(PGroup group, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void binaryChoice(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void binaryChoice(Pool pool, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void binaryChoice(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code)
          Directs the output to one of the two output channels depending on the boolean result of the provided closure.
 void bind(T value)
          Assigns a value to the variable.
 void bindError(java.lang.Throwable e)
           
 void bindSafely(T value)
          Assigns a value to the variable.
 void bindUnique(T value)
          Assigns a value to the variable.
private  void doBind(T value)
          Performs the actual bind operation, unblocks all blocked threads and informs all asynchronously waiting actors.
protected  void doBindImpl(T value)
           
 void doBindRemote(java.util.UUID hostId, T message)
          Binds the value after receiving a bing message over the wire
protected  T evaluate()
          Evaluates the expression after the ones we depend on are ready
 DataflowReadChannel<T> filter(groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
 DataflowReadChannel<T> filter(java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
 DataflowReadChannel<T> filter(PGroup group, groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
 DataflowReadChannel<T> filter(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
 DataflowReadChannel<T> filter(Pool pool, groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
 DataflowReadChannel<T> filter(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure)
          Creates and attaches a new operator that will filter data using the provided closure
private  void fireOnMessage(T value)
           
 DataflowChannelEventListenerManager<T> getEventManager()
          Retrieves the event manager object of this channel
 groovy.lang.MetaClass getMetaClass()
           
 java.lang.Object getProperty(java.lang.String propertyName)
          Returns either standard property of the expression or creates an expression, which will request given property when the receiver becomes available
 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 static void handleInterruption(java.util.concurrent.atomic.AtomicBoolean newWaiting)
           
<V> DataflowReadChannel<V>
chainWith(groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
<V> DataflowReadChannel<V>
chainWith(java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
<V> DataflowReadChannel<V>
chainWith(PGroup group, groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
<V> DataflowReadChannel<V>
chainWith(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
<V> DataflowReadChannel<V>
chainWith(Pool pool, groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
<V> DataflowReadChannel<V>
chainWith(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
 void choice(java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void choice(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void choice(PGroup group, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void choice(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void choice(Pool pool, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void choice(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code)
          Directs the output to one of the output channels depending on the int result of the provided closure.
 void into(DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 void into(java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 void into(PGroup group, DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 void into(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 void into(Pool pool, DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 void into(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
          Invokes the method on itself or creates an expression, which will invoke the method n the bound value, once it is available.
 boolean isBound()
          Check if value has been set already for this expression
 void join()
          Blocks, if the value has not been assigned yet to the DataflowVariable
 void join(long timeout, java.util.concurrent.TimeUnit units)
          Blocks, if the value has not been assigned yet to the DataflowVariable
 int length()
          Reports the current number of elements in the channel
<V> DataflowReadChannel<V>
merge(DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(java.util.Map<java.lang.String,java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(PGroup group, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(PGroup group, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(Pool pool, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(Pool pool, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
<V> DataflowReadChannel<V>
merge(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
          Merges channels together as inputs for a single dataflow operator.
private  void notifyRemote(java.util.UUID hostId)
          Sends notifications to all subscribers
<V> DataflowReadChannel<V>
or(groovy.lang.Closure<V> closure)
          Creates and attaches a new operator processing values from the channel
 void or(DataflowWriteChannel<T> target)
          Makes the output of the current channel to be an input for the specified channel
 DataflowExpression<T> poll()
          Retrieves the bound value.
<V> Promise<V>
rightShift(groovy.lang.Closure<V> closure)
          Schedule closure to be executed by pooled actor after data became available.
 void separate(java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void separate(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void separate(PGroup group, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void separate(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void separate(Pool pool, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void separate(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code)
          Allows the closure to output different values to different output channels.
 void setMetaClass(groovy.lang.MetaClass metaClass)
           
 void setProperty(java.lang.String propertyName, java.lang.Object newValue)
           
protected  void scheduleCallback(java.lang.Object attachment, MessageStream callback)
          Sends the result back to the actor, which is waiting asynchronously for the value to be bound.
 void split(DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
 void split(java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
 void split(PGroup group, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(PGroup group, java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
 void split(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
 void split(Pool pool, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(Pool pool, java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
 void split(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2)
          Splits the output of the current channel to be an input for the specified channels
 void split(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets)
          Makes the output of the current channel to be an input for the specified channels
protected  void subscribe()
          A utility method to call at the very end of constructors of derived expressions.
protected  void subscribe(DataflowExpression.DataflowExpressionsCollector listener)
           
 DataflowReadChannel<T> tap(DataflowWriteChannel<T> target)
          Taps into the pipeline.
 DataflowReadChannel<T> tap(java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Taps into the pipeline.
 DataflowReadChannel<T> tap(PGroup group, DataflowWriteChannel<T> target)
          Taps into the pipeline.
 DataflowReadChannel<T> tap(PGroup group, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Taps into the pipeline.
 DataflowReadChannel<T> tap(Pool pool, DataflowWriteChannel<T> target)
          Taps into the pipeline.
 DataflowReadChannel<T> tap(Pool pool, java.util.Map<java.lang.String,java.lang.Object> params, DataflowWriteChannel<T> target)
          Taps into the pipeline.
<V> Promise<V>
then(groovy.lang.Closure<V> closure)
          Schedule closure to be executed after data became available.
<V> Promise<V>
then(PGroup group, groovy.lang.Closure<V> closure)
          Schedule closure to be executed after data becomes available.
<V> Promise<V>
then(Pool pool, groovy.lang.Closure<V> closure)
          Schedule closure to be executed after data becomes available.
 java.lang.String toString()
           
static
<V> DataflowExpression<V>
transform(java.lang.Object another, groovy.lang.Closure closure)
          Transforms values bound eventually to dataflow variables using the supplied closure.
<V> void
whenBound(groovy.lang.Closure<V> closure)
          Schedule closure to be executed by pooled actor after data becomes available.
 void whenBound(MessageStream stream)
          Send the bound data to provided stream when it becomes available
<V> void
whenBound(PGroup group, groovy.lang.Closure<V> closure)
          Schedule closure to be executed by pooled actor after data becomes available.
<V> void
whenBound(Pool pool, groovy.lang.Closure<V> closure)
          Schedule closure to be executed by pooled actor after data becomes available.
<V> void
wheneverBound(groovy.lang.Closure<V> closure)
          Send all pieces of data bound in the future to the provided stream when it becomes available
 void wheneverBound(MessageStream stream)
          Send all pieces of data bound in the future to the provided stream when it becomes available.
 
Methods inherited from class groovyx.gpars.serial.WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTACHMENT

private static final java.lang.String ATTACHMENT
See Also:
Constant Field Values

RESULT

private static final java.lang.String RESULT
See Also:
Constant Field Values

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

metaClass

private groovy.lang.MetaClass metaClass
The current metaclass


value

protected volatile T value
Holds the actual value. Is null before a concrete value is bound to it.


error

protected volatile java.lang.Throwable error

state

protected final java.util.concurrent.atomic.AtomicInteger state
Holds the current state of the variable


waiting

private final java.util.concurrent.atomic.AtomicReference<DataflowExpression.WaitingThread> waiting
Points to the head of the chain of requests waiting for a value to be bound


S_NOT_INITIALIZED

protected static final int S_NOT_INITIALIZED
Possible states

See Also:
Constant Field Values

S_INITIALIZING

protected static final int S_INITIALIZING
See Also:
Constant Field Values

S_INITIALIZED

protected static final int S_INITIALIZED
See Also:
Constant Field Values

dummyWaitingThread

private static final DataflowExpression.WaitingThread dummyWaitingThread
A request chain terminator


eventManager

private volatile DataflowChannelEventOrchestrator<T> eventManager
Constructor Detail

DataflowExpression

protected DataflowExpression()
Creates a new unbound Dataflow Expression

Method Detail

isBound

public final boolean isBound()
Check if value has been set already for this expression

Specified by:
isBound in interface DataflowReadChannel<T>
Returns:
true if bound already

length

public final int length()
Description copied from interface: DataflowReadChannel
Reports the current number of elements in the channel

Specified by:
length in interface DataflowReadChannel<T>
Returns:
The current snapshot of the number of elements in the channel

getValAsync

public final void getValAsync(MessageStream callback)
Asynchronously retrieves the value of the variable. Sends the actual value of the variable as a message back the the supplied actor once the value has been bound. The actor can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow Variable.

Specified by:
getValAsync in interface DataflowReadChannel<T>
Parameters:
callback - An actor to send the bound value to.

getValAsync

public final void getValAsync(java.lang.Object attachment,
                              MessageStream callback)
Used by Dataflow operators. Asynchronously retrieves the value of the variable. Sends a message back the the supplied MessageStream with a map holding the supplied attachment under the 'attachment' key and the actual value of the variable under the 'result' key once the value has been bound. Attachment is an arbitrary value helping the actor.operator match its request with the reply. The actor/operator can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow Variable.

Specified by:
getValAsync in interface DataflowReadChannel<T>
Parameters:
attachment - arbitrary non-null attachment if reader needs better identification of result
callback - An actor to send the bound value plus the supplied index to.

join

public final void join()
                throws java.lang.InterruptedException
Blocks, if the value has not been assigned yet to the DataflowVariable

Throws:
java.lang.InterruptedException - If the current thread gets interrupted while waiting for the variable to be bound

join

public final void join(long timeout,
                       java.util.concurrent.TimeUnit units)
                throws java.lang.InterruptedException
Blocks, if the value has not been assigned yet to the DataflowVariable

Parameters:
timeout - The timeout value
units - Units for the timeout
Throws:
java.lang.InterruptedException - If the current thread gets interrupted while waiting for the variable to be bound

getVal

public T getVal()
         throws java.lang.InterruptedException
Reads the value of the variable. Blocks, if the value has not been assigned yet.

Specified by:
getVal in interface DataflowReadChannel<T>
Returns:
The actual value
Throws:
java.lang.InterruptedException - If the current thread gets interrupted while waiting for the variable to be bound

getVal

public T getVal(long timeout,
                java.util.concurrent.TimeUnit units)
         throws java.lang.InterruptedException
Reads the value of the variable. Blocks up to given timeout, if the value has not been assigned yet.

Specified by:
getVal in interface DataflowReadChannel<T>
Parameters:
timeout - The timeout value
units - Units for the timeout
Returns:
The actual value
Throws:
java.lang.InterruptedException - If the current thread gets interrupted while waiting for the variable to be bound

poll

public final DataflowExpression<T> poll()
Retrieves the bound value. Returns null, if no value is available.

Specified by:
poll in interface DataflowReadChannel<T>
Returns:
The value bound to the DFV or null
Throws:
java.lang.InterruptedException - If the current thread is interrupted

handleInterruption

private static void handleInterruption(java.util.concurrent.atomic.AtomicBoolean newWaiting)
                                throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

bindSafely

public final void bindSafely(T value)
Assigns a value to the variable. Returns silently if invoked on an already bound variable.

Parameters:
value - The value to assign

bindError

public final void bindError(java.lang.Throwable e)

bind

public final void bind(T value)
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable. Allows attempts to bind to equal values. Throws exception if invoked on an already bound variable.

Parameters:
value - The value to assign

bindUnique

public final void bindUnique(T value)
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable Doesn't allow attempts to bind to equal values. Throws exception if invoked on an already bound variable.

Parameters:
value - The value to assign

doBind

private void doBind(T value)
Performs the actual bind operation, unblocks all blocked threads and informs all asynchronously waiting actors.

Parameters:
value - The value to assign

doBindImpl

protected void doBindImpl(T value)

doBindRemote

public final void doBindRemote(java.util.UUID hostId,
                               T message)
Binds the value after receiving a bing message over the wire

Parameters:
hostId - Id of the bind originator host
message - The value to bind

notifyRemote

private void notifyRemote(java.util.UUID hostId)
Sends notifications to all subscribers

Parameters:
hostId - The local host id

scheduleCallback

protected void scheduleCallback(java.lang.Object attachment,
                                MessageStream callback)
Sends the result back to the actor, which is waiting asynchronously for the value to be bound. The message will either be a map holding the attachment under the 'attachment' key and the actual bound value under the 'result' key, or it will be the result itself if the callback doesn't care about the index.

Parameters:
attachment - An arbitrary object identifying the request
callback - The actor to send the message to

rightShift

public final <V> Promise<V> rightShift(groovy.lang.Closure<V> closure)
Schedule closure to be executed by pooled actor 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

Specified by:
rightShift in interface DataflowReadChannel<T>
Parameters:
closure - closure to execute when data becomes available. 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.

whenBound

public final <V> void whenBound(groovy.lang.Closure<V> closure)
Schedule closure to be executed by pooled actor after data becomes 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.

Specified by:
whenBound in interface DataflowReadChannel<T>
Parameters:
closure - closure to execute when data becomes available. The closure should take at most one argument.

whenBound

public <V> void whenBound(Pool pool,
                          groovy.lang.Closure<V> closure)
Schedule closure to be executed by pooled actor after data becomes 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.

Specified by:
whenBound in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use for task scheduling for asynchronous message delivery
closure - closure to execute when data becomes available. The closure should take at most one argument.

whenBound

public final <V> void whenBound(PGroup group,
                                groovy.lang.Closure<V> closure)
Schedule closure to be executed by pooled actor after data becomes 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.

Specified by:
whenBound in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use for task scheduling for asynchronous message delivery
closure - closure to execute when data becomes available. The closure should take at most one argument.

whenBound

public final void whenBound(MessageStream stream)
Send the bound data to provided stream when it becomes available

Specified by:
whenBound in interface DataflowReadChannel<T>
Parameters:
stream - stream where to send result

then

public final <V> Promise<V> then(groovy.lang.Closure<V> closure)
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

Specified by:
then in interface DataflowReadChannel<T>
Parameters:
closure - closure to execute when data becomes available. 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.

then

public final <V> Promise<V> then(Pool pool,
                                 groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes 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.

Specified by:
then in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use for task scheduling for asynchronous message delivery
closure - closure to execute when data becomes available. 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.

then

public final <V> Promise<V> then(PGroup group,
                                 groovy.lang.Closure<V> closure)
Schedule closure to be executed after data becomes 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.

Specified by:
then in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use for task scheduling for asynchronous message delivery
closure - closure to execute when data becomes available. 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.

wheneverBound

public final <V> void wheneverBound(groovy.lang.Closure<V> closure)
Send all pieces of data bound in the future to the provided stream when it becomes available. *

Specified by:
wheneverBound in interface DataflowReadChannel<T>
Parameters:
closure - closure to execute when data becomes available. The closure should take at most one argument.

wheneverBound

public final void wheneverBound(MessageStream stream)
Send all pieces of data bound in the future to the provided stream when it becomes available.

Specified by:
wheneverBound in interface DataflowReadChannel<T>
Parameters:
stream - stream where to send result

chainWith

public final <V> DataflowReadChannel<V> chainWith(groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

chainWith

public final <V> DataflowReadChannel<V> chainWith(Pool pool,
                                                  groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
pool - The thread pool to use
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

chainWith

public <V> DataflowReadChannel<V> chainWith(PGroup group,
                                            groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
group - The PGroup to use
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

chainWith

public final <V> DataflowReadChannel<V> chainWith(java.util.Map<java.lang.String,java.lang.Object> params,
                                                  groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

chainWith

public final <V> DataflowReadChannel<V> chainWith(Pool pool,
                                                  java.util.Map<java.lang.String,java.lang.Object> params,
                                                  groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

chainWith

public <V> DataflowReadChannel<V> chainWith(PGroup group,
                                            java.util.Map<java.lang.String,java.lang.Object> params,
                                            groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
chainWith in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

or

public <V> DataflowReadChannel<V> or(groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator processing values from the channel

Specified by:
or in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values returned from the supplied closure
Parameters:
closure - The function to invoke on all incoming values as part of the new operator's body
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(Pool pool,
                                     groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(PGroup group,
                                     groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(java.util.Map<java.lang.String,java.lang.Object> params,
                                     groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(Pool pool,
                                     java.util.Map<java.lang.String,java.lang.Object> params,
                                     groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

filter

public DataflowReadChannel<T> filter(PGroup group,
                                     java.util.Map<java.lang.String,java.lang.Object> params,
                                     groovy.lang.Closure<java.lang.Boolean> closure)
Description copied from interface: DataflowReadChannel
Creates and attaches a new operator that will filter data using the provided closure

Specified by:
filter in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
closure - The filter function to invoke on all incoming values to decide whether to pass the value on or not
Returns:
A channel of the same type as this channel, which the new operator will output into.

into

public void into(DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
target - The channel to copy data into

into

public void into(Pool pool,
                 DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
target - The channel to copy data into

into

public void into(PGroup group,
                 DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
target - The channel to copy data into

into

public void into(java.util.Map<java.lang.String,java.lang.Object> params,
                 DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to copy data into

into

public void into(Pool pool,
                 java.util.Map<java.lang.String,java.lang.Object> params,
                 DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to copy data into

into

public void into(PGroup group,
                 java.util.Map<java.lang.String,java.lang.Object> params,
                 DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
into in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to copy data into

or

public void or(DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channel

Specified by:
or in interface DataflowReadChannel<T>
Parameters:
target - The channel to copy data into

split

public void split(DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(Pool pool,
                  DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(PGroup group,
                  DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
targets - The channels to copy data into

split

public void split(Pool pool,
                  java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
targets - The channels to copy data into

split

public void split(PGroup group,
                  java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
targets - The channels to copy data into

split

public void split(java.util.Map<java.lang.String,java.lang.Object> params,
                  DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(Pool pool,
                  java.util.Map<java.lang.String,java.lang.Object> params,
                  DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(PGroup group,
                  java.util.Map<java.lang.String,java.lang.Object> params,
                  DataflowWriteChannel<T> target1,
                  DataflowWriteChannel<T> target2)
Description copied from interface: DataflowReadChannel
Splits the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target1 - The first channel to copy data into
target2 - The second channel to copy data into

split

public void split(java.util.Map<java.lang.String,java.lang.Object> params,
                  java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
targets - The channels to copy data into

split

public void split(Pool pool,
                  java.util.Map<java.lang.String,java.lang.Object> params,
                  java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
targets - The channels to copy data into

split

public void split(PGroup group,
                  java.util.Map<java.lang.String,java.lang.Object> params,
                  java.util.List<DataflowWriteChannel<T>> targets)
Description copied from interface: DataflowReadChannel
Makes the output of the current channel to be an input for the specified channels

Specified by:
split in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
targets - The channels to copy data into

tap

public DataflowReadChannel<T> tap(DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

tap

public DataflowReadChannel<T> tap(Pool pool,
                                  DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

tap

public DataflowReadChannel<T> tap(PGroup group,
                                  DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

tap

public DataflowReadChannel<T> tap(java.util.Map<java.lang.String,java.lang.Object> params,
                                  DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

tap

public DataflowReadChannel<T> tap(Pool pool,
                                  java.util.Map<java.lang.String,java.lang.Object> params,
                                  DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

tap

public DataflowReadChannel<T> tap(PGroup group,
                                  java.util.Map<java.lang.String,java.lang.Object> params,
                                  DataflowWriteChannel<T> target)
Description copied from interface: DataflowReadChannel
Taps into the pipeline. The supplied channel will receive a copy of all messages passed through.

Specified by:
tap in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
target - The channel to tap data into
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(Pool pool,
                                        DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
pool - The thread pool to use
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(PGroup group,
                                        DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
group - The PGroup to use
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(Pool pool,
                                        java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
pool - The thread pool to use
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(PGroup group,
                                        java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
group - The PGroup to use
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(java.util.Map<java.lang.String,java.lang.Object> params,
                                        DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(Pool pool,
                                        java.util.Map<java.lang.String,java.lang.Object> params,
                                        DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(PGroup group,
                                        java.util.Map<java.lang.String,java.lang.Object> params,
                                        DataflowReadChannel<java.lang.Object> other,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
other - The channel to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(java.util.Map<java.lang.String,java.lang.Object> params,
                                        java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(Pool pool,
                                        java.util.Map<java.lang.String,java.lang.Object> params,
                                        java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

merge

public <V> DataflowReadChannel<V> merge(PGroup group,
                                        java.util.Map<java.lang.String,java.lang.Object> params,
                                        java.util.List<DataflowReadChannel<java.lang.Object>> others,
                                        groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
Merges channels together as inputs for a single dataflow operator.

Specified by:
merge in interface DataflowReadChannel<T>
Type Parameters:
V - The type of values passed between the channels
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
others - The channels to merge with
closure - The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
Returns:
A channel of the same type as this channel, which the new operator will output into.

binaryChoice

public void binaryChoice(DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

binaryChoice

public void binaryChoice(Pool pool,
                         DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

binaryChoice

public void binaryChoice(PGroup group,
                         DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

binaryChoice

public void binaryChoice(java.util.Map<java.lang.String,java.lang.Object> params,
                         DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

binaryChoice

public void binaryChoice(Pool pool,
                         java.util.Map<java.lang.String,java.lang.Object> params,
                         DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

binaryChoice

public void binaryChoice(PGroup group,
                         java.util.Map<java.lang.String,java.lang.Object> params,
                         DataflowWriteChannel<T> trueBranch,
                         DataflowWriteChannel<T> falseBranch,
                         groovy.lang.Closure<java.lang.Boolean> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the two output channels depending on the boolean result of the provided closure.

Specified by:
binaryChoice in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
trueBranch - The channel to send data to if the closure returns true
falseBranch - The channel to send data to if the closure returns true
code - A closure directing data to either the true or the false output branch

choice

public void choice(java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
outputs - The channels to send data to of the closure returns true
code - A closure returning an index of the output channel to direct the data to

choice

public void choice(Pool pool,
                   java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
outputs - The channels to send data to.
code - A closure returning an index of the output channel to direct the data to

choice

public void choice(PGroup group,
                   java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
outputs - The channels to send data to.
code - A closure returning an index of the output channel to direct the data to

choice

public void choice(java.util.Map<java.lang.String,java.lang.Object> params,
                   java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to of the closure returns true
code - A closure returning an index of the output channel to direct the data to

choice

public void choice(Pool pool,
                   java.util.Map<java.lang.String,java.lang.Object> params,
                   java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to.
code - A closure returning an index of the output channel to direct the data to

choice

public void choice(PGroup group,
                   java.util.Map<java.lang.String,java.lang.Object> params,
                   java.util.List<DataflowWriteChannel<T>> outputs,
                   groovy.lang.Closure<java.lang.Integer> code)
Description copied from interface: DataflowReadChannel
Directs the output to one of the output channels depending on the int result of the provided closure.

Specified by:
choice in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to.
code - A closure returning an index of the output channel to direct the data to

separate

public void separate(java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

separate

public void separate(Pool pool,
                     java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

separate

public void separate(PGroup group,
                     java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

separate

public void separate(java.util.Map<java.lang.String,java.lang.Object> params,
                     java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

separate

public void separate(Pool pool,
                     java.util.Map<java.lang.String,java.lang.Object> params,
                     java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
pool - The thread pool to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

separate

public void separate(PGroup group,
                     java.util.Map<java.lang.String,java.lang.Object> params,
                     java.util.List<DataflowWriteChannel<?>> outputs,
                     groovy.lang.Closure<java.util.List<java.lang.Object>> code)
Description copied from interface: DataflowReadChannel
Allows the closure to output different values to different output channels.

Specified by:
separate in interface DataflowReadChannel<T>
Parameters:
group - The PGroup to use
params - Additional parameters to initialize the operator with (e.g. listeners or maxForks)
outputs - The channels to send data to.
code - A closure returning a list of values to pass to the output channels. Values are output to the output channels with identical index.

getEventManager

public DataflowChannelEventListenerManager<T> getEventManager()
Description copied from interface: DataflowReadChannel
Retrieves the event manager object of this channel

Specified by:
getEventManager in interface DataflowReadChannel<T>
Returns:
The event manager to register custom events listeners

fireOnMessage

private void fireOnMessage(T value)

transform

public static <V> DataflowExpression<V> transform(java.lang.Object another,
                                                  groovy.lang.Closure closure)
Transforms values bound eventually to dataflow variables using the supplied closure.

Type Parameters:
V - Type of the bound values
Parameters:
another - A list of DataflowVariables to transform
closure - The transformation function, which must take the same number of arguments as there are elements in the "another" list
Returns:
The value returned from the transformation closure.

subscribe

protected final void subscribe()
A utility method to call at the very end of constructors of derived expressions. Creates and subscribes a listener to monitor the expression


evaluate

protected T evaluate()
Evaluates the expression after the ones we depend on are ready

Returns:
The value to bind

subscribe

protected void subscribe(DataflowExpression.DataflowExpressionsCollector listener)

invokeMethod

public final java.lang.Object invokeMethod(java.lang.String name,
                                           java.lang.Object args)
Invokes the method on itself or creates an expression, which will invoke the method n the bound value, once it is available.

Specified by:
invokeMethod in interface groovy.lang.GroovyObject

getProperty

public final java.lang.Object getProperty(java.lang.String propertyName)
Returns either standard property of the expression or creates an expression, which will request given property when the receiver becomes available

Specified by:
getProperty in interface groovy.lang.GroovyObject
Parameters:
propertyName - The name of the property to retrieve
Returns:
The property value, instance of DataflowGetPropertyExpression

setMetaClass

public final void setMetaClass(groovy.lang.MetaClass metaClass)
Specified by:
setMetaClass in interface groovy.lang.GroovyObject

setProperty

public final void setProperty(java.lang.String propertyName,
                              java.lang.Object newValue)
Specified by:
setProperty in interface groovy.lang.GroovyObject

getMetaClass

public final groovy.lang.MetaClass getMetaClass()
Specified by:
getMetaClass in interface groovy.lang.GroovyObject

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

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