To wrap up our discussion of concurrency patterns, I will present a very important concept – the pipeline pattern. This pattern, which is sometimes also called staged processing, is not strictly a design pattern, but more of an architectural one. It is, nevertheless, one of the most important patterns you can use in parallel programming, which is why it is covered in this book.
If we are to be able to apply the pipeline pattern to a process, two conditions must be applied. First, the process must be able to process parts of the input one by one. In other words, we must be able to split the input into smaller blocks (processing units), which are processed sequentially. Second, the process itself must be doing the processing in separate steps (stages) that are executed one after another.
The pipeline works by passing the first processing unit to the first stage....