groovyx.gpars.dataflow
Class DataflowQueue<T>

java.lang.Object
  extended by groovyx.gpars.dataflow.DataflowQueue<T>
All Implemented Interfaces:
DataflowChannel<T>, DataflowReadChannel<T>, DataflowWriteChannel<T>
Direct Known Subclasses:
SyncDataflowQueue

public class DataflowQueue<T>
extends java.lang.Object
implements DataflowChannel<T>

Represents a thread-safe data flow stream. Values or DataflowVariables are added using the '<<' operator and safely read once available using the 'val' property. The iterative methods like each(), collect(), iterator(), any(), all() or the for loops work with snapshots of the stream at the time of calling the particular method. 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.

Author:
Vaclav Pech Date: Jun 5, 2009

Field Summary
private  DataflowChannelEventOrchestrator<T> eventManager
           
private  java.util.concurrent.LinkedBlockingQueue<DataflowVariable<T>> queue
          Stores the received DataflowVariables in the buffer.
private  java.lang.Object queueLock
          Internal lock
private  java.util.Queue<DataflowVariable<T>> requests
          Stores unsatisfied requests for values
private  java.util.Collection<MessageStream> wheneverBoundListeners
          A collection of listeners who need to be informed each time the stream is bound to a value
 
Constructor Summary
DataflowQueue()
           
 
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)
          Adds a DataflowVariable representing the passed in value to the buffer.
private  DataflowVariable<T> copyDFV(java.util.Queue<DataflowVariable<T>> from, java.util.Queue<DataflowVariable<T>> to)
           
protected  DataflowVariable<T> createVariable()
          Creates a new variable to perform the next data exchange
 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
(package private)  java.util.concurrent.LinkedBlockingQueue<DataflowVariable<T>> getQueue()
           
 T getVal()
          Retrieves the value at the head of the buffer.
 T getVal(long timeout, java.util.concurrent.TimeUnit units)
          Retrieves the value at the head of the buffer.
 void getValAsync(MessageStream callback)
          Asynchronously retrieves the value at the head of the buffer.
 void getValAsync(java.lang.Object attachment, MessageStream callback)
          Asynchronously retrieves the value at the head of the buffer.
private  DataflowExpression<T> hookWheneverBoundListeners(DataflowExpression<T> expr)
          Hooks the registered when bound handlers to the supplied dataflow expression
<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
 boolean isBound()
          Check if value has been set already for this expression
 java.util.Iterator<T> iterator()
          Returns an iterator over a current snapshot of the buffer's content.
 DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref)
          Adds a DataflowVariable to the buffer.
 DataflowWriteChannel<T> leftShift(T value)
          Adds a DataflowVariable representing the passed in value to the buffer.
 int length()
          Returns the current size of the buffer
<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.
<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 value at the head of the buffer.
private  DataflowVariable<T> retrieveForBind()
          Takes the first unsatisfied value request and binds a value on it.
private  DataflowVariable<T> retrieveOrCreateVariable()
          Checks whether there's a DFV waiting in the queue and retrieves it.
<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 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
 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()
           
<V> void
whenBound(groovy.lang.Closure<V> closure)
          Schedule closure to be executed by pooled actor after the next data becomes available.
 void whenBound(MessageStream stream)
          Send the next bound piece of data to the provided stream when it becomes available.
<V> void
whenBound(PGroup group, groovy.lang.Closure<V> closure)
          Schedule closure to be executed 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

queueLock

private final java.lang.Object queueLock
Internal lock


queue

private final java.util.concurrent.LinkedBlockingQueue<DataflowVariable<T>> queue
Stores the received DataflowVariables in the buffer.


requests

private final java.util.Queue<DataflowVariable<T>> requests
Stores unsatisfied requests for values


wheneverBoundListeners

private final java.util.Collection<MessageStream> wheneverBoundListeners
A collection of listeners who need to be informed each time the stream is bound to a value


eventManager

private volatile DataflowChannelEventOrchestrator<T> eventManager
Constructor Detail

DataflowQueue

public DataflowQueue()
Method Detail

leftShift

public final DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref)
Adds a DataflowVariable to the buffer. Implementation detail - in fact another DFV is added to the buffer and an asynchronous 'whenBound' handler is registered with the supplied DFV to update the one stored in the buffer.

Specified by:
leftShift in interface DataflowWriteChannel<T>
Parameters:
ref - The DFV to add to the stream
Returns:
The current channel instance

leftShift

public final DataflowWriteChannel<T> leftShift(T value)
Adds a DataflowVariable representing the passed in value to the buffer.

Specified by:
leftShift in interface DataflowWriteChannel<T>
Parameters:
value - The value to bind to the head of the stream
Returns:
The current channel instance

bind

public final void bind(T value)
Adds a DataflowVariable representing the passed in value to the buffer.

Specified by:
bind in interface DataflowWriteChannel<T>
Parameters:
value - The value to bind to the head of the stream

hookWheneverBoundListeners

private DataflowExpression<T> hookWheneverBoundListeners(DataflowExpression<T> expr)
Hooks the registered when bound handlers to the supplied dataflow expression

Parameters:
expr - The expression to hook all the when bound listeners to
Returns:
The supplied expression handler to allow method chaining

retrieveForBind

private DataflowVariable<T> retrieveForBind()
Takes the first unsatisfied value request and binds a value on it. If there are no unsatisfied value requests, a new DFV is stored in the queue.

Returns:
The DFV to bind the value on

copyDFV

private DataflowVariable<T> copyDFV(java.util.Queue<DataflowVariable<T>> from,
                                    java.util.Queue<DataflowVariable<T>> to)

createVariable

protected DataflowVariable<T> createVariable()
Creates a new variable to perform the next data exchange

Returns:
The newly created DataflowVariable instance

getVal

public final T getVal()
               throws java.lang.InterruptedException
Retrieves the value at the head of the buffer. Blocks until a value is available.

Specified by:
getVal in interface DataflowReadChannel<T>
Returns:
The value bound to the DFV at the head of the stream
Throws:
java.lang.InterruptedException - If the current thread is interrupted

getVal

public final T getVal(long timeout,
                      java.util.concurrent.TimeUnit units)
               throws java.lang.InterruptedException
Retrieves the value at the head of the buffer. Blocks until a value is available.

Specified by:
getVal in interface DataflowReadChannel<T>
Parameters:
timeout - The timeout value
units - Units for the timeout
Returns:
The value bound to the DFV at the head of the stream
Throws:
java.lang.InterruptedException - If the current thread is interrupted

poll

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

Specified by:
poll in interface DataflowReadChannel<T>
Returns:
The value bound to the DFV at the head of the stream or null

getValAsync

public final void getValAsync(MessageStream callback)
Asynchronously retrieves the value at the head of the buffer. 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 - The actor to notify when a value is bound

getValAsync

public final void getValAsync(java.lang.Object attachment,
                              MessageStream callback)
Asynchronously retrieves the value at the head of the buffer. Sends a message back the the supplied actor / operator with a map holding the supplied index under the 'index' key and the actual value of the variable under the 'result' key once the value has been bound. 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 - An arbitrary value to identify operator channels and so match requests and replies
callback - The actor / operator to notify when a value is bound

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 the next 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 final <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 <V> void whenBound(PGroup group,
                          groovy.lang.Closure<V> closure)
Description copied from interface: DataflowReadChannel
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:
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 next bound piece of data to the 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 <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 <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.

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

retrieveOrCreateVariable

private DataflowVariable<T> retrieveOrCreateVariable()
Checks whether there's a DFV waiting in the queue and retrieves it. If not, a new unmatched value request, represented by a new DFV, is added to the requests queue.

Returns:
The DFV to wait for value on

length

public final int length()
Returns the current size of the buffer

Specified by:
length in interface DataflowReadChannel<T>
Returns:
Number of DFVs in the queue

iterator

public final java.util.Iterator<T> iterator()
Returns an iterator over a current snapshot of the buffer's content. The next() method returns actual values not the DataflowVariables.

Returns:
AN iterator over all DFVs in the queue

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)

getQueue

final java.util.concurrent.LinkedBlockingQueue<DataflowVariable<T>> getQueue()

toString

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

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