Recursive Splitting, Task Stealing, and Algorithms
A number of concepts are fundamental to making the parallelism model of Threading Building Blocks intuitive. Most fundamental is the reliance on breaking problems up recursively as required to get to the right level of parallel tasks. It turns out that this works much better than the more obvious static division of work. It also fits perfectly with the use of task stealing instead of a global task queue. This is a critical design decision that avoids using a global resource as important as a task queue, which would limit scalability.
As you wrestle with which algorithm structure to apply for your parallelism (for loop, while loop, pipeline, divide and conquer, etc.), you will find that you want to combine them. If you realize that a combination such as a parallel_for loop controlling a parallel set of pipelines is what you want to program, you will find that easy to implement. Not only that, the fundamental design choice of recursion and task stealing makes this work yield efficient scalable applications.
Tip
It is a pleasant surprise to new users to discover how acceptable it is to code parallelism, even inside a routine that is used concurrently itself. Because Threading Building Blocks was designed to encourage this type of nesting, it makes parallelism easy to use. In other systems, this would be the start of a headache.
With an understanding of why Threading Building Blocks matters, we are ready for the next chapter, which lays ...