forked from taskflow/taskflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.cpp
More file actions
42 lines (33 loc) · 904 Bytes
/
simple.cpp
File metadata and controls
42 lines (33 loc) · 904 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
35
36
37
38
39
40
41
// A simple example to capture the following task dependencies.
//
// +---+
// +---->| B |-----+
// | +---+ |
// +---+ +-v-+
// | A | | D |
// +---+ +-^-+
// | +---+ |
// +---->| C |-----+
// +---+
//
#include <taskflow/taskflow.hpp> // the only include you need
int main(){
tf::Executor executor;
tf::Taskflow taskflow("simple");
auto [A, B, C, D] = taskflow.emplace(
[]() { std::cout << "TaskA\n"; },
[]() { std::cout << "TaskB\n"; },
[]() { std::cout << "TaskC\n"; },
[]() { std::cout << "TaskD\n"; }
);
A.name("A");
B.name("B");
C.name("C");
D.name("D");
A.precede(B, C); // A runs before B and C
D.succeed(B, C); // D runs after B and C
executor.run(taskflow).wait();
// dump the taskflow graph into a .dot format
taskflow.dump(std::cout);
return 0;
}