FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
taskflow/examples/cancel_async.cpp at master · yhcpp/taskflow · GitHub
yhcpp
/
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
taskflow
/
examples
/
cancel_async.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (19 loc) · 544 Bytes
Breadcrumbs
taskflow
/
examples
/
cancel_async.cpp
Copy path
File metadata and controls
28 lines (19 loc) · 544 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
//
The program demonstrates how to cancel submitted asynchronous tasks.
#
include
<
taskflow/taskflow.hpp
>
int
main
() {
tf::Executor executor;
std::vector<tf::Future<
void
>> futures;
//
submit 10000 asynchronous tasks
for
(
int
i=
0
; i<
10000
; i++) {
futures.
push_back
(executor.
async
([i](){
printf
(
"
task %d
\n
"
, i);
std::this_thread::sleep_for
(
std::chrono::milliseconds
(
100
));
}));
}
//
cancel all asynchronous tasks
for
(
auto
& fu : futures) {
fu.
cancel
();
}
executor.
wait_for_all
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL