GrPPI  0.2
Generic and Reusable Parallel Pattern Interface
seq/farm.h
Go to the documentation of this file.
1 
21 #ifndef GRPPI_SEQ_FARM_H
22 #define GRPPI_SEQ_FARM_H
23 
24 #include "sequential_execution.h"
25 
26 namespace grppi {
27 
45 template <typename Generator, typename Consumer>
47  Generator generate_op, Consumer consume_op)
48 {
49  for (;;) {
50  auto item{generate_op()};
51  if(!item) break;
52  consume_op(*item);
53  }
54 }
55 
67 template <typename Generator, typename Transformer, typename Consumer>
69  Generator generate_op, Transformer transform_op, Consumer consume_op)
70 {
71  for (;;) {
72  auto item{generate_op()};
73  if (!item) break;
74  consume_op(transform_op(*item));
75  }
76 }
77 
78 }
79 #endif
Definition: callable_traits.h:24
Sequential execution policy.
Definition: sequential_execution.h:31
auto farm(Execution &ex, Transformer &&transform_op)
Invoke Farm pattern on a data stream that can be composed in other streaming patterns.
Definition: farm.h:51