|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.operator.DataflowProcessor groovyx.gpars.dataflow.operator.DataflowSelector
public class 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. Selectors select a random value from the values available in the input channels. Optionally the selector's guards mask can be altered to limit the number of channels considered for selection.
Field Summary | |
---|---|
protected java.util.List<java.lang.Boolean> |
guards
|
protected Select |
select
|
Fields inherited from class groovyx.gpars.dataflow.operator.DataflowProcessor |
---|
actor, INPUTS, listeners, MAX_FORKS, OUTPUTS, STATE_OBJECT, stateObject |
Constructor Summary | |
---|---|
DataflowSelector(PGroup group,
java.util.Map channels,
groovy.lang.Closure code)
Creates a selector After creation the selector needs to be started using the start() method. |
Method Summary | |
---|---|
(package private) boolean |
allGuardsClosed()
Indicates, whether the selector has some guards enabled and so can select a value from the input channels |
private static java.lang.String |
countInputChannels(java.util.Map channels)
|
protected void |
doSelect()
Ask for another select operation on the internal select instance. |
void |
setGuard(int index,
boolean flag)
Used to enable/disable individual input channels from next selections |
void |
setGuards(java.util.List<java.lang.Boolean> flags)
Used to enable/disable individual input channels from next selections |
private static boolean |
verifyChannelParameters(java.util.Map channels,
int parameters)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Select select
protected final java.util.List<java.lang.Boolean> guards
Constructor Detail |
---|
public DataflowSelector(PGroup group, java.util.Map channels, groovy.lang.Closure code)
group
- A parallel group to use threads from in the internal actorchannels
- A map specifying "inputs" and "outputs" - dataflow channels (instances of the DataflowQueue or DataflowVariable classes) to use for inputs and outputscode
- The selector's body to run each time all inputs have a value to readMethod Detail |
---|
private static boolean verifyChannelParameters(java.util.Map channels, int parameters)
private static java.lang.String countInputChannels(java.util.Map channels)
public final void setGuard(int index, boolean flag)
index
- The index of the channel to enable/disableflag
- True, if the channel should be included in selection, false otherwisepublic final void setGuards(java.util.List<java.lang.Boolean> flags)
flags
- The flags to apply to channelsprotected void doSelect()
final boolean allGuardsClosed()
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |