Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56b4285

Browse files
author
“phrygiangates”
committed
complete class DataPipe and DataPipeline(only work with data_parallel_pipeline.cpp because of fixed buffer type)
1 parent d711bdf commit 56b4285

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

examples/data_parallel_pipeline

137 KB
Binary file not shown.

examples/data_parallel_pipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main() {
1313
// std::array<int, num_lines> buffer;
1414

1515
tf::DataPipeline pl(num_lines,
16-
tf::DataPipe<void, int>{tf::PipeType::SERIAL, [&](tf::Pipeflow& pf) -> int{
16+
tf::DataPipe<tf::Pipeflow&, int>{tf::PipeType::SERIAL, [&](tf::Pipeflow& pf) -> int{
1717
if(pf.token() == 5) {
1818
pf.stop();
1919
}

taskflow/algorithm/pipeline.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ class DataPipeline {
835835
std::vector<Task> _tasks;
836836
std::vector<Pipeflow> _pipeflows;
837837
//to modify
838-
std::vector<int> _buffer;
838+
std::vector<std::variant<int, std::string, float> > _buffer;
839839

840840
template <size_t... I>
841841
auto _gen_meta(std::tuple<Ps...>&&, std::index_sequence<I...>);
@@ -963,11 +963,11 @@ void DataPipeline<Ps...>::_on_pipe(Pipeflow& pf, Runtime& rt) {
963963
if constexpr (std::is_invocable_v<callable_t, Pipeflow&>) {
964964
_buffer[pf._line] = pipe._callable(pf);
965965
}
966-
else if constexpr (std::is_invocable_v<callable_t, int>) {
966+
else if constexpr (std::is_invocable_v<callable_t, input_t>) {
967967
if constexpr (std::is_void_v<output_t>) {
968-
pipe._callable(_buffer[pf._line]);
968+
pipe._callable(std::get<input_t>(_buffer[pf._line]));
969969
} else {
970-
_buffer[pf._line] = pipe._callable(_buffer[pf._line]);
970+
_buffer[pf._line] = pipe._callable(std::get<input_t>(_buffer[pf._line]));
971971
}
972972
}
973973
else if constexpr(std::is_invocable_v<callable_t, Pipeflow&, Runtime&>) {

0 commit comments

Comments
 (0)