Classes | Typedefs | Functions
test_tbb_join.cxx File Reference
#include <tbb/flow_graph.h>
#include <iostream>

Go to the source code of this file.

Classes

struct  CountDown
 
struct  MyJoin
 
struct  Chirp
 
struct  TupleHelper< TupleType, N >
 
struct  TupleHelper< TupleType, 0 >
 
struct  Adder
 

Typedefs

typedef tbb::flow::receiver< int > int_receiver
 

Functions

int main ()
 

Typedef Documentation

typedef tbb::flow::receiver<int> int_receiver

Definition at line 45 of file test_tbb_join.cxx.

Function Documentation

int main ( void  )

Definition at line 103 of file test_tbb_join.cxx.

104 {
106 
107  typedef tbb::flow::source_node<int> int_source;
108  vector<int_source> countdowns;
109 
110  int n = 3; // explicitly nonconst
111  for (int i=0; i<n; ++i) {
112  countdowns.push_back(int_source(graph,CountDown(i),false));
113  }
114 
115  // join
116  typedef std::tuple<int,int,int> IntTriple;
118 
119  typedef tbb::flow::join_node< IntTriple > JoinInt3;
120  JoinInt3 jn(graph);
121  vector<int_receiver*> jrec = th.input_ports(jn);
122 
123  tbb::flow::function_node< std::tuple<int,int,int>, vector<int> > bo(graph, 0, th);
124  tbb::flow::function_node< vector<int>, int > fn(graph, 0, Adder());
125 
126  for (int i=0; i<n; ++i) {
127  make_edge(countdowns[i],*jrec[i]);
128  }
129  make_edge(jn, bo);
130  make_edge(bo, fn);
131  for (int i=0; i<n; ++i) {
132  countdowns[i].activate();
133  }
134 
135  graph.wait_for_all();
136 }
vector< int_receiver * > input_ports(tbb::flow::join_node< TupleType > &jn)
def graph(desc, maker=maker)
Definition: apa.py:294
QAsciiDict< Entry > fn
std::size_t n
Definition: format.h:3399