In this chapter, we will learn how to properly handle concurrency, synchronization, and parallelism in C++. Here, it is essential that you have a general knowledge of C++ and C++ threads. This chapter is important because working with C++ typically requires the use of shared resources, which can easily become corrupt if thread-safety is not implemented properly. We will start with an extensive overview of std::mutexes, which provides a means to synchronizing C++ threads. We will then look at atomic data types, which provide another mechanism for handling parallelism safely.
This chapter has recipes that demonstrate how to handle different scenarios while working with C++ threads, including handling const &, thread-safety wrapping, blocking versus asynchronous programming, and C++ promises and futures. This is important, as this knowledge is...