C++ Concurrency in Action
Practical Multithreading
Anthony Williams
  • February 2012
  • ISBN 9781933988771
  • 528 pages
  • printed in black & white

A thoughtful, in-depth guide, straight from the mouth of one of the horses

Neil Horlock, Credit Suisse

C++ Concurrency in Action is a reference and guide to the new C++ 11 Standard for experienced C++ programmers as well as those who have never written multithreaded code. This book will show you how to write robust multithreaded applications in C++ while avoiding many common pitfalls.

Table of Contents show full



about this book

about the cover illustration

1. Hello, world of concurrency in C++!

1.1. What is concurrency?

1.2. Why use concurrency?

1.3. Concurrency and multithreading in C++

1.4. Getting started

1.5. Summary

2. Managing threads

2.1. Basic thread management

2.2. Passing arguments to a thread function

2.3. Transferring ownership of a thread

2.4. Choosing the number of threads at runtime

2.5. Identifying threads

2.6. Summary

3. Sharing data between threads

3.1. Problems with sharing data between threads

3.2. Protecting shared data with mutexes

3.3. Alternative facilities for protecting shared data

3.4. Summary

4. Synchronizing concurrent operations

4.1. Waiting for an event or other condition

4.2. Waiting for one-off events with futures

4.3. Waiting with a time limit

4.4. Using synchronization of operations to simplify code

4.5. Summary

5. The C++ memory model and operations on atomic types

5.1. Memory model basics

5.2. Atomic operations and types in C++

5.3. Synchronizing operations and enforcing ordering

5.4. Summary

6. Designing lock-based concurrent data structures

6.1. What does it mean to design for concurrency?

6.2. Lock-based concurrent data structures

6.3. Designing more complex lock-based data structures

6.4. Summary

7. Designing lock-free concurrent data structures

7.1. Definitions and consequences

7.2. Examples of lock-free data structures

7.3. Guidelines for writing lock-free data structures

7.4. Summary

8. Designing concurrent code

8.1. Techniques for dividing work between threads

8.2. Factors affecting the performance of concurrent code

8.3. Designing data structures for multithreaded performance

8.4. Additional considerations when designing for concurrency

8.5. Designing concurrent code in practice

8.6. Summary

9. Advanced thread management

9.1. Thread pools

9.2. Interrupting threads

9.3. Summary

10. Testing and debugging multithreaded applications

10.3. Summary

Appendix A: Brief reference for some C++11 language features

Appendix B: Brief comparison of concurrency libraries

Appendix C: A message-passing framework and complete ATM example

Appendix D: C++ Thread Library reference



About the Technology

Multiple processors with multiple cores are the norm these days. The C++11 version of the C++ language offers beefed-up support for multithreaded applications, and requires that you master the principles, techniques, and new language features of concurrency to stay ahead of the curve.

About the book

Without assuming you have a background in the subject, C++ Concurrency in Action gradually enables you to write robust and elegant multithreaded applications in C++11. You'll explore the threading memory model, the new multithreading support library, and basic thread launching and synchronization facilities. Along the way, you'll learn how to navigate the trickier bits of programming for concurrency.

What's inside

  • Written for the new C++11 Standard
  • Programming for multiple cores and processors
  • Small examples for learning, big examples for practice

About the reader

Written for C++ programmers who are new to concurrency and others who may have written multithreaded code using other languages, APIs, or platforms.

About the author

Anthony Williams is a UK-based developer and consultant with many years experience in C++. He has been an active member of the BSI C++ Standards Panel since 2001, and is author or coauthor of many of the C++ Standards Committee papers that led up to the inclusion of the thread library in the new C++ Standard, known as C++11 or C++0x. He has been the maintainer of the Boost Thread library since 2006, and is the developer of the just::thread implementation of the C++11 thread library from Just Software Solutions Ltd. Anthony lives in the far west of Cornwall, England.

combo $69.99 pBook + eBook
eBook $55.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Simplifies the dark art of C++ multithreading.

Rick Wagner, Red Hat

Reading this made my brain hurt. But it's a good hurt.

Joshua Heyer, Ingersoll Rand

Anthony shows how to put concurrency into practice.

Roger Orr, OR/2 Limited