1 #include <tbb/flow_graph.h> 6 namespace dfp = tbb::flow;
9 template<
typename DataType>
16 cerr <<
"number_source with " << dat.size() <<
" element " <<
endl;
18 cerr <<
"\tempty" <<
endl;
22 dat.erase(dat.begin());
23 cerr <<
"\treturning value: " << out <<
endl;
28 typedef dfp::multifunction_node<int, tbb::flow::tuple<float> >
int2float_node;
31 void operator()(
const int& in, int2float_node::output_ports_type& op) {
33 bool ok = std::get<0>(op).try_put(f);
35 cerr <<
"cast " << in <<
" to " << f <<
endl;
38 cerr <<
"FAILED " << in <<
" to " << f <<
endl;
52 std::vector<int> numbers{5,4,3,2,1,0};
54 dfp::function_node<int, int> int_chirp_node(g, dfp::unlimited, [](
const int &v) {
55 cerr <<
"i value: " << v <<
endl;
57 cerr <<
"...woke, returning i=" << v <<
endl;
60 dfp::function_node<float,float> float_chirp_node(g, dfp::unlimited, [](
const float &v) {
61 cerr <<
"f value: " << v <<
endl;
63 cerr <<
"...woke, returning f=" << v <<
endl;
68 cerr <<
"make edges" <<
endl;
69 make_edge(number_source_node, int_chirp_node);
70 make_edge(int_chirp_node, i2fcaster_node);
71 make_edge(dfp::output_port<0>(i2fcaster_node), float_chirp_node);
73 cerr <<
"Activate source" <<
endl;
74 number_source_node.activate();
75 cerr <<
"Waiting for graph" <<
endl;
void operator()(const int &in, int2float_node::output_ports_type &op)
def graph(desc, maker=maker)
number_source(const vector_type &d)
dfp::multifunction_node< int, tbb::flow::tuple< float > > int2float_node
bool operator()(data_type &out)
millisecond milliseconds
Alias for common language habits.
std::vector< data_type > vector_type
QTextStream & endl(QTextStream &s)