FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/example/emplace.cpp at master · WhyBingo/cpp-taskflow · GitHub
WhyBingo
/
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
/
example
/
emplace.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (27 loc) · 926 Bytes
Breadcrumbs
cpp-taskflow
/
example
/
emplace.cpp
Copy path
File metadata and controls
37 lines (27 loc) · 926 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
34
35
36
37
//
This example shows how to create task using either 'emplace'
//
or 'silent_emplace'.
#
include
<
cassert
>
#
include
<
taskflow/taskflow.hpp
>
int
main
(){
tf::Taskflow tf;
//
The method emplace gives you a future to retrieve the result.
//
You may pass this future to another thread or program context
//
to enable more asynchronous control flows.
auto
[A, fuA] = tf.
emplace
([] () {
std::cout <<
"
Task A
\n
"
;
return
1
;
});
A.
name
(
"
A
"
);
//
The method silent_emplace won't give you a future.
//
Therefore, you won't be able to get the return value of the callable.
//
Typically, silent_emplace is used for callables with no return values.
auto
B = tf.
silent_emplace
([] () {
std::cout <<
"
Task B
\n
"
;
return
"
no one can get me
"
;
});
B.
name
(
"
B
"
);
//
The future of A won't be ready until you execute the taskflow.
tf.
wait_for_all
();
assert
(fuA.
get
() ==
1
);
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL