File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,8 +153,11 @@ target_link_libraries(dynamic_traversal ${PROJECT_NAME} Threads::Threads)
153153add_executable (framework ${TF_EXAMPLE_DIR} /framework.cpp )
154154target_link_libraries (framework ${PROJECT_NAME} Threads::Threads )
155155
156- #add_executable(dataflow ${TF_EXAMPLE_DIR}/dataflow.cpp)
157- #target_link_libraries(dataflow ${PROJECT_NAME} Threads::Threads)
156+ add_executable (dice_pools ${TF_EXAMPLE_DIR} /dice_pools.cpp )
157+ target_link_libraries (dice_pools ${PROJECT_NAME} Threads::Threads )
158+
159+ add_executable (get_best_dice ${TF_EXAMPLE_DIR} /get_best_dice.cpp )
160+ target_link_libraries (get_best_dice ${PROJECT_NAME} Threads::Threads )
158161
159162add_executable (composition ${TF_EXAMPLE_DIR} /composition.cpp )
160163target_link_libraries (composition ${PROJECT_NAME} Threads::Threads )
Original file line number Diff line number Diff line change 1+ // 2019/02/25 - contributed by Paolo Bolzoni
2+ // - a generic wrapper for dataflow
3+
14#ifndef DATAFLOW_HPP
25#define DATAFLOW_HPP 1
36
@@ -44,7 +47,8 @@ class Dataflow_generator;
4447// For convenience output pads can be accessed with the [] operator
4548template <typename T>
4649class Node {
47- public:
50+
51+ public:
4852 // get input pad
4953 T const & ipad (Pad_id<T> id) const ;
5054
@@ -58,8 +62,7 @@ class Node {
5862 // get all the output pad ids
5963 std::vector< Pad_id<T> > const & opad_list () const ;
6064
61-
62- private:
65+ private:
6366 std::vector<T>& pads_;
6467 std::vector< Pad_id<T> > ipads_;
6568 std::vector< Pad_id<T> > opads_;
@@ -86,7 +89,7 @@ class Node {
8689// execution is done via taskflow taskflow.run_until
8790template <typename T>
8891class Dataflow_generator {
89- public:
92+ public:
9093 // creates a new node
9194 Node_id<T> create_node ();
9295
@@ -112,7 +115,7 @@ class Dataflow_generator {
112115 void start_flow_once ();
113116
114117 Dataflow_generator () = default ;
115- private:
118+ private:
116119 std::vector<T> pads_;
117120 std::vector< Node<T> > nodes_;
118121 std::vector<tf::Task> tasks_;
Original file line number Diff line number Diff line change @@ -122,19 +122,20 @@ void write_out(Node& node) {
122122
123123
124124int main () {
125- Dataflow_generator gg{};
126125
127- auto output = gg.create_node (write_out);
128- auto pickup = gg.create_node (pick_up_max);
129- gg.create_arc (pickup, output);
126+ Dataflow_generator gg{};
130127
131- // try to increase or reduce the number of dice pools
132- int nr_dice_pools{ 5 };
133- while (nr_dice_pools-- > 0 ) {
134- gg.create_arc (gg.create_node (Fill_up_vector{}), pickup);
135- }
128+ auto output = gg.create_node (write_out);
129+ auto pickup = gg.create_node (pick_up_max);
130+ gg.create_arc (pickup, output);
131+
132+ // try to increase or reduce the number of dice pools
133+ int nr_dice_pools{ 5 };
134+ while (nr_dice_pools-- > 0 ) {
135+ gg.create_arc (gg.create_node (Fill_up_vector{}), pickup);
136+ }
136137
137- int times{ 10 };
138- gg.start_flow ([×]() { return times-- == 0 ; });
138+ int times{ 10 };
139+ gg.start_flow ([×]() { return times-- == 0 ; });
139140}
140141
You can’t perform that action at this time.
0 commit comments