Author: Anthony Williams
Aimed at: C++ developers
Pros: Starts from the basics
Cons: Gets difficult - its unavoidable
Reviewed by: Mike James
The free lunch is over. Now that processors are going multicore rather than faster we need to master concurrency.
C++ Concurrency in Action promises to be about "practical multithreading" and for the most part it is. This is not an easy book to read, but it is one that will increase your understanding. I can do no better than quote a reader's comment from the back jacket:
"Reading this made my brain hurt. But it's a good hurt."
The book aims to explain how to do multithreading using C++11, but many of the ideas are general and would help you no matter what language you are working in. The good thing is that the book starts of from the very basic.
You get to find out what is concurrency and write a simple "hello world" threaded program in Chapter 1. From here, we learn about managing threads and sharing data between threads. This is where race conditions and locks are first introduced. Chapter 4 takes us on into more sophisticated synchronization primitives.Chapter 5 introduces atomic operations and the C++ memory model.
Chapter 6 and 7 start a section on actually using the basic facilities and a look at building data structures using locks or lock-free respectively. The final three chapters deal with more advanced topics - design issues, thread pools and testing and debugging.
All of the ideas are well described and there are lots of examples to make things clear. However, if you have no background in concurrent programming at all, you will still find it hard work. Concurrent programming is a tough challenge. There is also the small added challenge that many C++11 features are used throughout the book. If you are still learning the new version then there is help in the appendixes.
As this is one of the first books on the topic of concurrency in C++11, it is worth getting hold of. It is a good introduction in the sense that it helps you see why the techniques are needed and how to avoid misusing them. Occasionally you might need to look things up elsewhere to complete an explanation.
If you want to get involved in concurrency in C++11 then this is an excellent place to start.