FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cpp-taskflow/examples/parallel_data_pipeline.cpp at master · ezhangle/cpp-taskflow · GitHub
ezhangle
/
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
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cpp-taskflow
/
examples
/
parallel_data_pipeline.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (38 loc) · 1.34 KB
Breadcrumbs
cpp-taskflow
/
examples
/
parallel_data_pipeline.cpp
Copy path
File metadata and controls
50 lines (38 loc) · 1.34 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
//
This program demonstrates how to use tf::DataPipeline to create
//
a pipeline with in-pipe data automatically managed by the Taskflow
//
library.
#
include
<
taskflow/taskflow.hpp
>
#
include
<
taskflow/algorithm/data_pipeline.hpp
>
int
main
() {
//
dataflow => void -> int -> std::string -> float -> void
tf::Taskflow
taskflow
(
"
pipeline
"
);
tf::Executor executor;
const
size_t
num_lines =
3
;
//
create a pipeline graph
tf::DataPipeline
pl
(num_lines,
tf::make_data_pipe<
void
,
int
>(tf::PipeType::
SERIAL
, [&](tf::Pipeflow& pf) {
if
(pf.
token
() ==
5
) {
pf.
stop
();
return
0
;
}
else
{
printf
(
"
first pipe returns %zu
\n
"
, pf.
token
());
return
static_cast
<
int
>(pf.
token
());
}
}),
tf::make_data_pipe<
int
, std::string>(tf::PipeType::
SERIAL
, [](
int
& input) {
printf
(
"
second pipe returns a strong of %d
\n
"
, input +
100
);
return
std::to_string
(input +
100
);
}),
tf::make_data_pipe<std::string,
void
>(tf::PipeType::
SERIAL
, [](std::string& input) {
printf
(
"
third pipe receives the input string %s
\n
"
, input.
c_str
());
})
);
//
build the pipeline graph using composition
taskflow.
composed_of
(pl).
name
(
"
pipeline
"
);
//
dump the pipeline graph structure (with composition)
taskflow.
dump
(std::cout);
//
run the pipeline
executor.
run
(taskflow).
wait
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL