Practical examples
Now it’s time to implement some examples to tackle real-life scenarios using std::async
. We will learn how to do the following:
- Perform parallel computation and aggregation
- Asynchronously search across different containers or a large dataset
- Asynchronously multiply two matrices
- Chain asynchronous operations
- Improve the pipeline example from the last chapter
Parallel computation and aggregation
Data aggregation is the process of collecting raw data from multiple sources and organizing, processing, and providing a summary of the data for easy consumption. This process is useful in many fields, such as business reporting, financial services, healthcare, social media monitoring, research, and academia.
As a naive example, let’s compute the result of squaring all numbers between 1 and n and obtaining their average value. We know that using the following formula to compute the sum of square values would be much quicker...