8 #include <tbb/flow_graph.h> 17 cerr <<
"CountDown("<<index <<
" , " <<
n<<
")\n";
21 cerr <<
"CountDown("<<index<<
"): EOS\n";
25 cerr <<
"CountDown("<<index<<
"): " << x <<
endl;
33 for (
auto x : in) { out +=
x; }
47 template<
class TupleType,
int N>
51 vector<int_receiver*>
input_ports(tbb::flow::join_node<TupleType>& jn) {
52 vector<int_receiver*> ret = nm1helper.input_ports(jn);
54 ret.insert(ret.begin(), rec);
59 vector<int> ret = nm1helper.values(t);
61 ret.insert(ret.begin(),
val);
72 template<
class TupleType>
75 vector<int_receiver*>
input_ports(tbb::flow::join_node<TupleType>& jn) {
76 return vector<int_receiver*>();
98 cerr <<
" = " << tot <<
"\n";
107 typedef tbb::flow::source_node<int> int_source;
108 vector<int_source> countdowns;
111 for (
int i=0; i<
n; ++i) {
112 countdowns.push_back(int_source(graph,
CountDown(i),
false));
116 typedef std::tuple<int,int,int> IntTriple;
119 typedef tbb::flow::join_node< IntTriple > JoinInt3;
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());
126 for (
int i=0; i<
n; ++i) {
127 make_edge(countdowns[i],*jrec[i]);
131 for (
int i=0; i<
n; ++i) {
132 countdowns[i].activate();
135 graph.wait_for_all();
void operator()(const int &x)
CountDown(int index, int n=10)
vector< int > values(const TupleType &t)
vector< int_receiver * > input_ports(tbb::flow::join_node< TupleType > &jn)
def graph(desc, maker=maker)
int operator()(const vector< int > &in)
vector< int > values(const TupleType &t)
tbb::flow::receiver< int > int_receiver
vector< int_receiver * > input_ports(tbb::flow::join_node< TupleType > &jn)
vector< int > operator()(const TupleType &t)
bool operator()(const vector< int > &in, int &out)
TupleHelper< TupleType, N-1 > nm1helper
auto const & get(AssnsNode< L, R, D > const &r)
QTextStream & endl(QTextStream &s)