GrPPI  1.0
Generic and Reusable Parallel Pattern Interface
pipeline.h
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Universidad Carlos III de Madrid
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef GRPPI_PIPELINE_H
17 #define GRPPI_PIPELINE_H
18 
19 #include <utility>
20 
21 #include "common/callable_traits.h"
24 
25 namespace grppi {
26 
44 template <typename Execution, typename Generator, typename ... Transformers,
45  requires_execution_supported<std::decay_t<Execution>> = 0>
46 void pipeline(
47  const Execution & ex,
48  Generator && generate_op,
49  Transformers && ... transform_ops)
50 {
51  static_assert(supports_pipeline<std::decay_t<Execution>>(),
52  "pipeline pattern is not supported by execution type");
53  ex.pipeline(std::forward<Generator>(generate_op),
54  std::forward<Transformers>(transform_ops)...);
55 }
56 
67 template <typename Transformer, typename ... Transformers,
68  requires_execution_not_supported<std::decay_t<Transformer>> = 0>
69 auto pipeline(
70  Transformer && transform_op,
71  Transformers && ... transform_ops)
72 {
73  return pipeline_t<Transformer, Transformers...>(
74  std::forward<Transformer>(transform_op),
75  std::forward<Transformers>(transform_ops)...);
76 }
82 }
83 
84 #endif
Representation of pipeline pattern. Represents a pipeline with multiple chained transformers.
Definition: pipeline_pattern.h:30
void pipeline(const Execution &ex, Generator &&generate_op, Transformers &&... transform_ops)
Invoke Pipeline pattern on a data stream.
Definition: pipeline.h:46
Definition: callable_traits.h:21
constexpr bool supports_pipeline()
Determines if an execution policy supports the pipeline pattern.
Definition: execution_traits.h:78