groovyx.gpars.dataflow.operator
Class DataflowPrioritySelector

java.lang.Object
  extended by groovyx.gpars.dataflow.operator.DataflowProcessor
      extended by groovyx.gpars.dataflow.operator.DataflowSelector
          extended by groovyx.gpars.dataflow.operator.DataflowPrioritySelector

public final class DataflowPrioritySelector
extends DataflowSelector

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 so that once values are available to be consumed in any of the input channels the selector's body is triggered on the values, potentially generating values to be written into 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.

Priority selectors prefer to select messages from channels with lower position index.

Author:
Vaclav Pech Date: Sep 23, 2009

Field Summary
 
Fields inherited from class groovyx.gpars.dataflow.operator.DataflowSelector
guards, select
 
Fields inherited from class groovyx.gpars.dataflow.operator.DataflowProcessor
actor, INPUTS, listeners, MAX_FORKS, OUTPUTS, STATE_OBJECT, stateObject
 
Constructor Summary
DataflowPrioritySelector(PGroup group, java.util.Map<java.lang.String,java.lang.Object> channels, groovy.lang.Closure code)
          Creates a priority selector After creation the selector needs to be started using the start() method.
 
Method Summary
 void doSelect()
          Ask for another select operation on the internal select instance.
 
Methods inherited from class groovyx.gpars.dataflow.operator.DataflowSelector
allGuardsClosed, setGuard, setGuards
 
Methods inherited from class groovyx.gpars.dataflow.operator.DataflowProcessor
addDataflowEventListener, bindAllOutputs, bindAllOutputsAtomically, bindAllOutputValues, bindAllOutputValuesAtomically, bindOutput, bindOutput, extractInputs, extractOutputs, fireAfterRun, fireAfterStart, fireAfterStop, fireBeforeRun, fireControlMessageArrived, fireCustomEvent, fireMessageArrived, fireMessageSentOut, fireOnException, getOutput, getOutputs, getOutputs, getStateObject, checkMaxForks, join, registerChannelListenersToAllInputs, removeDataflowEventListener, reportError, shouldBeMultiThreaded, start, start, terminate, terminateAfterNextRun
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataflowPrioritySelector

public DataflowPrioritySelector(PGroup group,
                                java.util.Map<java.lang.String,java.lang.Object> channels,
                                groovy.lang.Closure code)
Creates a priority selector After creation the selector needs to be started using the start() method.

Parameters:
group - A parallel group to use threads from in the internal actor
channels - A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputs
code - The selector's body to run each time all inputs have a value to read
Method Detail

doSelect

public void doSelect()
Ask for another select operation on the internal select instance. The selector's guards are applied to the selection.

Overrides:
doSelect in class DataflowSelector

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