25 #include <tbb/flow_graph.h> 34 std::cerr <<
"CountDown("<<index <<
" , " <<
n<<
")\n";
38 std::cerr <<
"CountDown("<<index<<
"): EOS\n";
42 std::cerr <<
"CountDown("<<index<<
"): " << x <<
std::endl;
47 class Adder :
public tbb::flow::composite_node< std::tuple< int, int >, std::tuple< int > > {
48 tbb::flow::join_node< std::tuple<int, int>, queueing >
j;
49 tbb::flow::function_node< std::tuple< int, int >,
int >
f;
50 typedef tbb::flow::composite_node< std::tuple< int, int >, std::tuple< int > >
base_type;
54 int n = (std::get<1>(
t)+1)/2;
55 int sum = std::get<0>(
t) + std::get<1>(t);
56 std::cout <<
"Sum of the first " << n <<
" positive odd numbers is " << n <<
" squared: " << sum <<
std::endl;
64 base_type::input_ports_type input_tuple(input_port<0>(j), input_port<1>(j));
65 base_type::output_ports_type output_tuple(f);
66 base_type::set_external_ports(input_tuple, output_tuple);
CountDown(int index, int n=10)
tbb::flow::function_node< std::tuple< int, int >, int > f
Adder(tbb::flow::graph &g)
def graph(desc, maker=maker)
tbb::flow::composite_node< std::tuple< int, int >, std::tuple< int > > base_type
IFrame::pointer sum(std::vector< IFrame::pointer > frames, int ident)
tbb::flow::join_node< std::tuple< int, int >, queueing > j
int operator()(const std::tuple< int, int > &t)
QTextStream & endl(QTextStream &s)