org.codehaus.gpars

groovyx.gpars.dataflow.operator
[Groovy] Class DataflowProcessor

java.lang.Object
  groovyx.gpars.dataflow.operator.DataflowProcessor

abstract class DataflowProcessor
extends java.lang.Object

Dataflow selectors and operators (processors) form the basic units in dataflow networks. They are typically combined into oriented graphs that transform data. They accept a set of input and output dataflow channels and following specific strategies they transform input values from the input channels into new values written to the output channels. The output channels at the same time are suitable to be used as input channels by some other dataflow processors. The channels allow processors to communicate. Dataflow selectors and operators enable creation of highly concurrent applications yet the abstraction hides the low-level concurrency primitives and exposes much friendlier API. Since selectors and operators internally leverage the actor implementation, they reuse a pool of threads and so the actual number of threads used by the calculation can be kept much lower than the actual number of processors used in the network.

Authors:
Vaclav Pech Date: Sep 9, 2009


Field Summary
protected Actor actor

The internal actor performing on behalf of the processor

 
Constructor Summary
protected DataflowProcessor(java.util.Map channels, groovy.lang.Closure code)

Creates a processor After creation the processor needs to be started using the start() method.

 
Method Summary
void bindAllOutputValues(java.lang.Object values)

Used by the processor's body to send a value to all output channels.

void bindAllOutputValuesAtomically(java.lang.Object values)

Used by the processor's body to send a value to all output channels, while guaranteeing atomicity of the operation and preventing other calls to bindAllOutputsAtomically() from interfering with one another.

void bindAllOutputs(java.lang.Object value)

Used by the processor's body to send a value to all output channels.

void bindAllOutputsAtomically(java.lang.Object value)

Used by the processor's body to send a value to all output channels, while guaranteeing atomicity of the operation and preventing other calls to bindAllOutputsAtomically() from interfering with one another.

void bindOutput(int idx, java.lang.Object value)

Used by the processor's body to send a value to the given output channel

void bindOutput(java.lang.Object value)

Used by the processor's body to send a value to the first / only output channel

java.lang.Object getOutput()

The processor's first / only output channel

java.lang.Object getOutputs(int idx)

The processor's output channel of the given index

java.lang.Object getOutputs()

The processor's output channel of the given index

void join()

Joins the processor waiting for it to finish

protected void reportError(java.lang.Throwable e)

Is invoked in case the actor throws an exception.

protected boolean shouldBeMultiThreaded(java.util.Map channels)

DataflowProcessor start(PGroup group)

Starts a processor using the specified parallel group

DataflowProcessor start()

Starts a processor using the specified parallel group

void stop()

Stops the processor

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

actor

protected Actor actor
The internal actor performing on behalf of the processor


 
Constructor Detail

DataflowProcessor

protected DataflowProcessor(java.util.Map channels, groovy.lang.Closure code)
Creates a processor After creation the processor needs to be started using the start() method.
Parameters:
channels - A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputs
code - The processor's body to run each time all inputs have a value to read


 
Method Detail

bindAllOutputValues

final void bindAllOutputValues(java.lang.Object values)
Used by the processor's body to send a value to all output channels. The values passed as arguments will each be sent to an output channel with identical position index. If the maxForks value is set to a value greater than 1, calls to bindAllOutputs may result in values written to different channels to be in different order. If this is a problem for the application logic, the bindAllOutputsAtomically method should be considered instead.
Parameters:
values - Values to send to output channels of the same position index


bindAllOutputValuesAtomically

@SuppressWarnings("GroovySynchronizedMethod")
final void bindAllOutputValuesAtomically(java.lang.Object values)
Used by the processor's body to send a value to all output channels, while guaranteeing atomicity of the operation and preventing other calls to bindAllOutputsAtomically() from interfering with one another. The values passed as arguments will each be sent to an output channel with identical position index.
Parameters:
values - Values to send to output channels of the same position index


bindAllOutputs

final void bindAllOutputs(java.lang.Object value)
Used by the processor's body to send a value to all output channels. If the maxForks value is set to a value greater than 1, calls to bindAllOutputs may result in values written to different channels to be in different order. If this is a problem for the application logic, the bindAllOutputsAtomically method should be considered instead.


bindAllOutputsAtomically

@SuppressWarnings("GroovySynchronizedMethod")
final void bindAllOutputsAtomically(java.lang.Object value)
Used by the processor's body to send a value to all output channels, while guaranteeing atomicity of the operation and preventing other calls to bindAllOutputsAtomically() from interfering with one another.


bindOutput

final void bindOutput(int idx, java.lang.Object value)
Used by the processor's body to send a value to the given output channel


bindOutput

final void bindOutput(java.lang.Object value)
Used by the processor's body to send a value to the first / only output channel


getOutput

final java.lang.Object getOutput()
The processor's first / only output channel


getOutputs

final java.lang.Object getOutputs(int idx)
The processor's output channel of the given index


getOutputs

final java.lang.Object getOutputs()
The processor's output channel of the given index


join

final void join()
Joins the processor waiting for it to finish


reportError

protected void reportError(java.lang.Throwable e)
Is invoked in case the actor throws an exception.


shouldBeMultiThreaded

protected boolean shouldBeMultiThreaded(java.util.Map channels)


start

final DataflowProcessor start(PGroup group)
Starts a processor using the specified parallel group
Parameters:
group - The parallel group to use with the processor


start

final DataflowProcessor start()
Starts a processor using the specified parallel group


stop

final void stop()
Stops the processor


 

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