In part
1 and part
2 we have explored some techniques that allow us to build
simple future-like computation chains without type-erasure
or allocations. While our examples demonstrated the idea of nesting
computations by moving *this into a parent node
(resulting in “huge types”), they did not implement any
operation that could be executed in parallel.
Our goal is to have a new when_all node type at the end
of this article, which takes an arbitrary amount of
Callable objects, invokes them in
parallel, aggregates the results, and invokes an eventual
continuation afterwards. We’ll do this in a non-blocking
manner: the thread that completes the last
Callable will continue executing the rest of the
computation chain without blocking or context-switching.