Template Class pipeline_builder¶
Defined in File pipeline.hpp
Class Documentation¶
-
template<typename
T>
classconcore::v1::pipeline_builder¶ Front-end to create pipeline objects by adding stages, step by step.
This tries to extract the building of the pipeline stages from the
pipeline class.- Template Parameters
T: The type of the data corresponding to a line.
It just knows how to configure a pipeline and then to create an actual pipeline object.
After we get a pipeline object, this builder cannot be used anymore.
Example of building a pipeline:
auto my_pipeline = concore::pipeline_builder<MyT>() | concore::stage_ordering::concurrent | [&](MyT data) { work1(data); } | concore::stage_ordering::out_of_order | [&](MyT data) { work2(data); } | concore::pipeline_end;
- See
Public Functions
-
pipeline_builder(int max_concurrency = 0xffff)¶ Constructs a pipeline object.
- Parameters
max_concurrency: The concurrency limit for the pipeline
-
pipeline_builder(int max_concurrency, task_group grp)¶ Constructs a pipeline object.
- Parameters
max_concurrency: The concurrency limit for the pipelinegrp: The group in which tasks need to be executed
-
pipeline_builder(int max_concurrency, task_group grp, any_executor exe)¶ Constructs a pipeline object.
- Parameters
max_concurrency: The concurrency limit for the pipelinegrp: The group in which tasks need to be executedexe: The executor to be used by the pipeline
-
pipeline_builder(int max_concurrency, any_executor exe)¶ Constructs a pipeline object.
- Parameters
max_concurrency: The concurrency limit for the pipelineexe: The executor to be used by the pipeline
-
template<typename
F>
pipeline_builder &add_stage(stage_ordering ord, F &&work)¶ Adds a stage to the pipeline.
This takes a functor of type
void (T)and an ordering and constructs a stage in the pipeline with them.- Parameters
ord: The ordering for the stagework: The work to be done in this stage
- Template Parameters
F: The type of the work
- See
stage_ordering
-
operator pipeline<T>()¶ Creates the actual pipeline object, ready to process items.
After calling this, we can no longer own any pipeline data, and we cannot add stages any longer. The returned pipeline object is ready to process items with the stages defined by this class.
-
pipeline<T>
build()¶ Creates the actual pipeline object, ready to process items.
After calling this, we can no longer own any pipeline data, and we cannot add stages any longer. The returned pipeline object is ready to process items with the stages defined by this class.
- Return
Resulting pipeline object.
-
pipeline_builder &
operator|(stage_ordering ord)¶ Pipe operator to specify the ordering for the next stages.
This allows easily constructing pipelines by using the
|operator.- Return
The same pipeline_builder object
- Parameters
ord: The ordering to be applied to next stages
-
template<typename
F>
pipeline_builder &operator|(F &&work)¶ Pipe operator to add new stages to the pipeline.
This adds a new stage to the pipeline, using the latest specified stage ordering. If no stage ordering is specified, before adding this stage, the
in_orderis used.- Return
The same pipeline_builder object
- Parameters
work: The work corresponding to the stage; needs to be of typevoid(T)
- Template Parameters
F: The type of the functor
-
pipeline<T>
operator|(pipeline_end_t)¶ Pipe operator to a tag that tells us that we are done building the pipeline.
This will actually finalize the building process and return the corresponding
pipeline object. After this is called, any other operations on the builder are illegal.- Return
The pipeline object built by this pipeline_builder object.