-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathsimple.cpp
More file actions
34 lines (26 loc) · 945 Bytes
/
simple.cpp
File metadata and controls
34 lines (26 loc) · 945 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
// 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 = taskflow.emplace([](){ std::cout << "TaskA\n"; }).name("A");
auto B = taskflow.emplace([](){ std::cout << "TaskB\n"; }).name("B");
auto C = taskflow.emplace([](){ std::cout << "TaskC\n"; }).name("C");
auto D = taskflow.emplace([](){ std::cout << "TaskD\n"; }).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();
taskflow.dump(std::cout); // dump the graph to a DOT format via standard output
return 0;
}