Classes | Typedefs | Functions
test_tbb.cxx File Reference
#include <tbb/flow_graph.h>
#include <iostream>
#include <tuple>
#include <chrono>
#include <thread>

Go to the source code of this file.

Classes

struct  number_source< DataType >
 
struct  I2Fcaster
 

Typedefs

typedef dfp::multifunction_node< int, tbb::flow::tuple< float > > int2float_node
 

Functions

void msleep (int msec)
 
int main ()
 

Typedef Documentation

typedef dfp::multifunction_node<int, tbb::flow::tuple<float> > int2float_node

Definition at line 28 of file test_tbb.cxx.

Function Documentation

int main ( void  )

Definition at line 50 of file test_tbb.cxx.

50  {
51  dfp::graph g;
52  std::vector<int> numbers{5,4,3,2,1,0};
53  dfp::source_node<int> number_source_node(g, number_source<int>(numbers), false);
54  dfp::function_node<int, int> int_chirp_node(g, dfp::unlimited, [](const int &v) {
55  cerr << "i value: " << v << endl;
56  msleep(v*100);
57  cerr << "...woke, returning i=" << v << endl;
58  return v;
59  });
60  dfp::function_node<float,float> float_chirp_node(g, dfp::unlimited, [](const float &v) {
61  cerr << "f value: " << v << endl;
62  msleep(v*100);
63  cerr << "...woke, returning f=" << v << endl;
64  return v;
65  });
66  int2float_node i2fcaster_node(g, dfp::unlimited, I2Fcaster());
67 
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);
72 
73  cerr << "Activate source" << endl;
74  number_source_node.activate();
75  cerr << "Waiting for graph" << endl;
76  g.wait_for_all();
77  return 0;
78 }
def graph(desc, maker=maker)
Definition: apa.py:294
void msleep(int msec)
Definition: test_tbb.cxx:45
static const double g
Definition: Units.h:145
dfp::multifunction_node< int, tbb::flow::tuple< float > > int2float_node
Definition: test_tbb.cxx:28
QTextStream & endl(QTextStream &s)
void msleep ( int  msec)

Definition at line 45 of file test_tbb.cxx.

46 {
47  std::this_thread::sleep_for(std::chrono::milliseconds(msec));
48 }
millisecond milliseconds
Alias for common language habits.
Definition: spacetime.h:100