groovyx.gpars.dataflow
Class SyncDataflowQueue<T>

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

public final class SyncDataflowQueue<T>
extends DataflowQueue<T>

Represents a thread-safe synchronous 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.

Unlike DataflowQueue, which exchanges data asynchronously, SyncDataflowQueue blocks the writer until a reader is ready to consume the message.

Author:
Vaclav Pech Date: Jun 5, 2009

Constructor Summary
SyncDataflowQueue()
           
 
Method Summary
protected  DataflowVariable<T> createVariable()
          Creates a new variable to perform the next data exchange
<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>
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.
 DataflowReadChannel<T> tap(PGroup group, DataflowWriteChannel<T> target)
          Taps into the pipeline.
 java.lang.String toString()
           
 
Methods inherited from class groovyx.gpars.dataflow.DataflowQueue
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, bind, filter, filter, filter, filter, filter, filter, getEventManager, getQueue, getVal, getVal, getValAsync, getValAsync, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, into, into, into, into, into, into, isBound, iterator, leftShift, leftShift, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, or, or, poll, rightShift, separate, separate, separate, separate, separate, separate, split, split, split, split, split, split, split, split, split, split, split, split, tap, tap, tap, tap, tap, then, then, then, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SyncDataflowQueue

public SyncDataflowQueue()
Method Detail

createVariable

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

Overrides:
createVariable in class DataflowQueue<T>
Returns:
The newly created SyncDataflowVariable instance with exactly one expected reader

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>
Overrides:
chainWith in class DataflowQueue<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.

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>
Overrides:
tap in class DataflowQueue<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.

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>
Overrides:
merge in class DataflowQueue<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.

toString

public java.lang.String toString()
Overrides:
toString in class DataflowQueue<T>

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