Summary
In this chapter, we discussed the concept of concurrency and showed how it is different from parallelism. We learned about the difference between a process and a thread – the latter being of interest. Multithreading allows us to manage a program so that it’s more efficient, though this also brings additional complexity. To handle data races, we can use synchronization primitives such as mutexes. A mutex is a way to lock the data used by one thread to avoid invalid behavior being produced by simultaneously accessing the same data from several threads.
We also covered the idea that an I/O operation is considered blocking and that asynchronous functions are one of the ways to make it non-blocking. Coroutines, as part of asynchronously executing code, were introduced in C++20.
Finally, we learned how to create and start a thread. More importantly, we learned how to manage data between threads. In the next chapter, we will dive into data structures that are used...