Summary
This chapter has introduced atomic types and operations, the C++ memory model, and a basic implementation of an SPSC lock-free queue.
The following is a summary of what we have looked at:
- The C++ Standard Library atomic types and operations, what they are, and how to use them with some examples.
- The C++ memory model, and especially the different memory orderings it defines. Bear in mind that this is a very complex subject and that this section was just a basic introduction to it.
- How to implement a basic SPSC lock-free queue. As we mentioned previously, we will demonstrate how to improve its performance in Chapter 13. Examples of performance-improving actions include eliminating false sharing (what happens when two variables are in the same cache line and each variable is just modified by one thread) and reducing true sharing. Don’t worry if you don’t understand any of this now. We will cover it later and demonstrate how to run performance...