Name
parallel_while Template Class — Template class that processes work items.
Synopsis
#include "tbb/parallel_while.h" template<typename Body> class parallel_while;
Description
A parallel_while<Body> performs parallel iteration over items. The processing to be performed on each item is defined by a function object of type Body. The items are specified in two ways:
An initial stream of items
Additional items that are added while the stream is being processed
Table 4-1 shows the requirements on the stream and body.
Table 4-1. Requirements for parallel_while stream and body
|
Pseudosignature |
Semantics |
|---|---|
|
|
Get next stream item. |
|
|
Process item. |
|
|
Default constructor. |
|
|
Copy constructor. |
|
|
Destructor. |
For example, a unary function object, as defined in Section 20.3 of the C++ standard, models the requirements for B. A concurrent_queue models the requirements for S.
Tip
To achieve speedup, the grain size of B::operator() needs to be on the order of 10,000 instructions to execute. Otherwise, the internal over-heads of parallel_while swamp the useful work. The parallelism in parallel_while is not scalable if all the items come from the input stream. To achieve ...