REVIEW - C++ Concurrency in Action


C++ Concurrency in Action


Anthony Williams


Manning Publications (2012)




Francis Glassborow


June 2012



The author will be familiar to members of ACCU and those attending ACCU Conferences. Indeed anyone who attended his talk at the recent ACCU 2012 conference will probably already have bought a copy of this book.

C++11 (AKA C++0x) introduces a new memory model for C++ along with substantial support for concurrent programming. Some programmers (indeed originally quite a few members of WG21) think that multi-threaded programming is just a matter of using pthreads or some derivative of it. This is not the case. Many of our multi-threaded programs only scrape by because they have been running on a single processor. Indeed a great deal of 1990s thinking about multiple threads was based on that situation. We did not have to concern ourselves with the problems that arise when two processors simultaneously want access to the same data. It didn't happen, one or other got there first. Of course the indeterminacy of the order might cause problems but that is not the same as genuine concurrency. Over the last few years we have moved on to a world where even our mobile phones have multiple cores (I can still remember the shock of discovering that C++ on the Symbian OS back in 2004 had to handle at least dual core processors in mobiles). Our programs need to be able to make use of the hardware. There is no point in running a program that needs good performance on a 16-core processor if our code has a single thread of execution.

So many of us know that we need to write concurrent code. Up until now the problem has been that doing so has meant using proprietary libraries and extensions. As of C++11 that has changed. It is now possible to write portable multi-threaded code.

Being able to do so is not the same as doing it. In addition there are various considerations that guide us to the most effective code for our purposes.

We need to consider issues of sharing data, synchronising operations, lock based versus lock-free and how to debug concurrent code.

Anthony covers all these and more in his book.

I found this book a pleasure to read and surprised myself with how quickly it helped me to progress in an area that I had previously avoided like the plague.

If you already use multiple threads you may think that you can simply dive straight into C++11. Well you may be right but my guess is that, in doing so, you will miss many of the tools that those who spent 8 long years working on concurrency for C++11 have provided. The library largely masks all the hard work by hiding its use in the internals of various classes but knowing these classes exist and what they offer will be a great help both to the newcomer to programming for concurrency and for the old hand.

Unless you have been as involved with the development of concurrency in C++ as the author has been, you will find this book a great help in bringing you up to speed on this important area of C++11. It is written in clear English and neither patronises nor assumes knowledge that some readers will not have. This is a book that you owe it to yourself to read, and read diligently and thoughtfully. Not to be read in the bath (well a few bits can be) but to be read alongside a computer running an up-to-date C++ implementation. In order to write this review I had to find a copy of MinGW with g++ 4.7 and discover how to use it from Code::Blocks. That in itself was an excellent piece of learning and sent me away with a warm fuzzy feeling of still being able to learn new things despite being in sight of my biblical three score years and ten. I felt even better as I worked through the text and discovered that I could actually manage it. Very timely as my publishers are showing interest in a new edition of my book, 'You Can Do It!', for inquisitive lay people (i.e. those who want to know what programming is about without intending to make a living from it).

Thank you Anthony for writing this book, I hope that many others choose to benefit from it as I have.

Book cover image courtesy of Open Library.

Your Privacy

By clicking "Accept All Cookies" you agree ACCU can store cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

By clicking "Share IP Address" you agree ACCU can forward your IP address to third-party sites to enhance the information presented on the site, and that these sites may store cookies on your device.