#include "tbb/pipeline.h"
class pipeline;
A pipeline represents pipelined application of a series of filters to a stream of items. Each filter operates in a particular mode: parallel, serial in-order, or serial out-of-order (MacDonald 2004).
A pipeline contains one or more filters, denoted here as fi , where i denotes the position of the filter in the pipeline. The pipeline starts with filter f0, followed by f1, f2, etc. The following steps describe how to use class pipeline.
Given sufficient processors and tokens, the throughput of the pipeline is limited to the throughput of the slowest serial filter.
Function parallel_pipeline provides a strongly typed lambda-friendly way to build and run pipelines.
namespace tbb { class pipeline { public: pipeline(); ~pipeline(); void add_filter( filter& f ); void run( size_t max_number_of_live_tokens [, task_group_context& group ] ); void clear(); }; }
Though the current implementation declares the destructor virtual, do not rely on this detail. The virtual nature is deprecated and may disappear in future versions of Intel® Threading Building Blocks (Intel® TBB).
Member | Description |
---|---|
pipeline() |
Constructs pipeline with no filters. |
~pipeline() |
Removes all filters from the pipeline and destroys the pipeline. |
void add_filter( filter& f ) |
Appends filter f to sequence of filters in the pipeline. The filter f must not already be in a pipeline. |
void run( size_t max_number_of_live_tokens[, task_group_context& group] ) |
Runs the pipeline until the first filter returns NULL and each subsequent filter has processed all items from its predecessor. The number of items processed in parallel depends upon the structure of the pipeline and number of available threads. At most max_number_of_live_tokens are in flight at any given time. A pipeline can be run multiple times. It is safe to add stages between runs. Concurrent invocations of run on the same instance of pipeline are prohibited. If the group argument is specified, pipeline’s tasks are executed in this group. By default the algorithm is executed in a bound group of its own. |
void clear() |
Removes all filters from the pipeline. |