FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/examples/nested_if_else.cpp at master · feiyunwill/cpp-taskflow · GitHub
feiyunwill
/
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
/
nested_if_else.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
34 lines (25 loc) · 989 Bytes
Breadcrumbs
cpp-taskflow
/
examples
/
nested_if_else.cpp
Copy path
File metadata and controls
34 lines (25 loc) · 989 Bytes
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
//
This program demonstrates how to create nested if-else control flow
//
using condition tasks.
#
include
<
taskflow/taskflow.hpp
>
int
main
() {
tf::Executor executor;
tf::Taskflow taskflow;
int
i;
//
create three condition tasks for nested control flow
auto
initi = taskflow.
emplace
([&](){ i=
3
; });
auto
cond1 = taskflow.
emplace
([&](){
return
i>
1
?
1
:
0
; });
auto
cond2 = taskflow.
emplace
([&](){
return
i>
2
?
1
:
0
; });
auto
cond3 = taskflow.
emplace
([&](){
return
i>
3
?
1
:
0
; });
auto
equl1 = taskflow.
emplace
([&](){ std::cout <<
"
i=1
\n
"
; });
auto
equl2 = taskflow.
emplace
([&](){ std::cout <<
"
i=2
\n
"
; });
auto
equl3 = taskflow.
emplace
([&](){ std::cout <<
"
i=3
\n
"
; });
auto
grtr3 = taskflow.
emplace
([&](){ std::cout <<
"
i>3
\n
"
; });
initi.
precede
(cond1);
cond1.
precede
(equl1, cond2);
cond2.
precede
(equl2, cond3);
cond3.
precede
(equl3, grtr3);
//
dump the conditioned flow
taskflow.
dump
(std::cout);
executor.
run
(taskflow).
wait
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL