Case Studies
After presenting the theory of the memory model and the multithreading interface, I apply the theory in a few case studies.
Calculating the Sum of a Vector
Calculating the sum of an vector can be done in various ways. You can do it sequentially, or concurrently with maximum and minimum sharing of data. The performance numbers differ drastically.
Thread-Safe Initialisation of a Singleton
Thread-safe initialisation of a singleton is the classical use-case for thread-safe initialisation of a shared variable. There are many ways to do it, with varying performance characteristics.
Ongoing Optimisation with CppMem
I start with a small program and successively improve it. I verify each step of my process of ongoing optimisation with CppMem. CppMem is an interactive tool for exploring the behaviour of small code snippets using the C++ memory model.