forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_condition.cpp
More file actions
35 lines (27 loc) · 776 Bytes
/
multi_condition.cpp
File metadata and controls
35 lines (27 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// This program demonstrates how to use multi-condition task
// to jump to multiple successor tasks
//
// A ----> B
// |
// |---> C
// |
// |---> D
//
#include <taskflow/taskflow.hpp>
int main() {
tf::Executor executor;
tf::Taskflow taskflow("Multi-Conditional Tasking Demo");
auto A = taskflow.emplace([&]() -> tf::SmallVector<int> {
std::cout << "A\n";
return {0, 2};
}).name("A");
auto B = taskflow.emplace([&](){ std::cout << "B\n"; }).name("B");
auto C = taskflow.emplace([&](){ std::cout << "C\n"; }).name("C");
auto D = taskflow.emplace([&](){ std::cout << "D\n"; }).name("D");
A.precede(B, C, D);
// visualizes the taskflow
taskflow.dump(std::cout);
// executes the taskflow
executor.run(taskflow).wait();
return 0;
}