GrPPI
0.2
Generic and Reusable Parallel Pattern Interface
|
The stream iteration pattern allows loops in data stream processing. An operation is applied to a data item until a predicate is satisfied. When the predicate is met, the result is sent to the output stream.
The interface to the stream iteration pattern is provided by function grppi::repeat_until()
. As all functions in GrPPI, this function takes as its first argument an execution policy.
There is a single variant:
Note: Although there is a single variant of stream iteration, the transformation applied in the iteration loop may be some other composable pattern (farm or pipeline).
The key elements in a stream iteration are a Transformer used to transform data items, and a Predicate that defines when the iteration should finish.
The Transformer may be any C++ callable entity that takes a data item and applies a transformation to it. Thus, a Transformer op
is any operation that, given an input value x
of type T
makes valid the following:
The Predicate may be any C++ callable entity that takes a data item and returns a value that is contextually convertible to bool
. Thus, a predicate pred
is any operation, that given a value x
of type T
, makes the following valid:
A stand-alone stream iteration also has a Generator. The generator may be any C++ callable entity that produces values in a way that allows to signal an indication of end-of stream. For this purpose, the stream iteration requires that the generator produces values of any type that is compatible with a subset of an optional interface:
Additionally, a filter may have a Consumer. The consumer may be any C++ callable entity that takes values of the result type of the Transformer.
A stand alone stream iteration has four elements: