FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/examples/simple.cpp at master · iplayfast/cpp-taskflow · GitHub
iplayfast
/
cpp-taskflow
Public
forked from
taskflow/taskflow
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
examples
/
simple.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (54 loc) · 2.15 KB
Breadcrumbs
cpp-taskflow
/
examples
/
simple.cpp
Copy path
File metadata and controls
67 lines (54 loc) · 2.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
A simple example to capture the following task dependencies.
//
//
TaskA---->TaskB---->TaskD
//
TaskA---->TaskC---->TaskD
#
include
<
taskflow/taskflow.hpp
>
//
the only include you need
int
main
(){
tf::Taskflow
taskflow
(
"
Error 1: no source
"
);
auto
E = taskflow.
emplace
([](){}).
name
(
"
E
"
);
auto
C = taskflow.
emplace
([](){
return
::
rand
()%
2
; }).
name
(
"
C
"
);
auto
D = taskflow.
emplace
([](){}).
name
(
"
D
"
);
auto
D_aux = taskflow.
emplace
([](){}).
name
(
"
D_aux
"
);
auto
F = taskflow.
emplace
([](){}).
name
(
"
F
"
);
E.
precede
(D);
C.
precede
(D_aux, F);
D_aux.
precede
(D);
taskflow.
dump
(std::cout);
//
tf::Taskflow taskflow1("taskflow1");
//
tf::Taskflow taskflow2("taskflow2");
//
auto [A, B] = taskflow1.emplace(
//
[] () { std::cout << "TaskA"; },
//
[] () { std::cout << "TaskB"; }
//
);
//
A.precede(B);
//
//
auto [C, D] = taskflow2.emplace(
//
[] () { std::cout << "TaskC"; },
//
[] (tf::Subflow& sf) {
//
std::cout << "TaskD";
//
auto [D1, D2] = sf.emplace(
//
[] () { std::cout << "D1"; },
//
[] () { std::cout << "D2"; }
//
);
//
D1.precede(D2);
//
}
//
);
//
C.precede(D);
//
auto E = taskflow2.composed_of(taskflow1);
//
D.precede(E);
//
executor.run(taskflow2).wait();
//
taskflow2.dump(std::cout);
//
auto A = taskflow.emplace([]() { std::cout << "TaskA\n"; });
//
auto B = taskflow.emplace([]() { std::cout << "TaskB\n"; });
//
auto C = taskflow.emplace([]() { std::cout << "TaskC\n"; });
//
auto D = taskflow.emplace([]() { std::cout << "TaskD\n"; });
//
A.precede(B); // B runs after A // +---+
//
A.precede(C); // C runs after A // +---->| B |-----+
//
B.precede(D); // D runs after B // | +---+ |
//
C.precede(D); // D runs after C // +---+ +-v-+
//
// | A | | D |
//
// +---+ +-^-+
//
executor.run(taskflow).wait(); // | +---+ |
//
// +---->| C |-----+
//
return 0; // +---+
}
Back
|
FazBrowse Home
|
New Git URL