C++ Concurrency in Action, Second Edition

Book Description

C++ Concurrency in Action, Second Edition is the definitive guide to writing elegant multithreaded applications in C++. Updated for C++ 17, it carefully addresses every aspect of concurrent development, from starting new threads to designing fully functional multithreaded algorithms and data structures. Concurrency master Anthony Williams presents examples and practical tasks in every chapter, including insights that will delight even the most experienced developer.

Table of Contents

  1. Copyright
    1. Dedication
  2. Brief Table of Contents
  3. Table of Contents
  4. Praise for the first edition
  5. Preface
  6. Acknowledgments
  7. About this book
    1. Roadmap
    2. Who should read this book
    3. How to use this book
    4. Code conventions and downloads
    5. Software requirements
    6. Book forum
  8. About the author
  9. About the cover illustration
  10. Chapter 1. Hello, world of concurrency in C++!
    1. 1.1. What is concurrency?
    2. 1.2. Why use concurrency?
    3. 1.3. Concurrency and multithreading in C++
    4. 1.4. Getting started
    5. Summary
  11. Chapter 2. Managing threads
    1. 2.1. Basic thread management
    2. 2.2. Passing arguments to a thread function
    3. 2.3. Transferring ownership of a thread
    4. 2.4. Choosing the number of threads at runtime
    5. 2.5. Identifying threads
    6. Summary
  12. Chapter 3. Sharing data between threads
    1. 3.1. Problems with sharing data between threads
    2. 3.2. Protecting shared data with mutexes
    3. 3.3. Alternative facilities for protecting shared data
    4. Summary
  13. Chapter 4. Synchronizing concurrent operations
    1. 4.1. Waiting for an event or other condition
    2. 4.2. Waiting for one-off events with futures
    3. 4.3. Waiting with a time limit
    4. 4.4. Using synchronization of operations to simplify code
    5. Summary
  14. Chapter 5. The C++ memory model and operations on atomic types
    1. 5.1. Memory model basics
    2. 5.2. Atomic operations and types in C++
    3. 5.3. Synchronizing operations and enforcing ordering
    4. Summary
  15. Chapter 6. Designing lock-based concurrent data structures
    1. 6.1. What does it mean to design for concurrency?
    2. 6.2. Lock-based concurrent data structures
    3. 6.3. Designing more complex lock-based data structures
    4. Summary
  16. Chapter 7. Designing lock-free concurrent data structures
    1. 7.1. Definitions and consequences
    2. 7.2. Examples of lock-free data structures
    3. 7.3. Guidelines for writing lock-free data structures
    4. Summary
  17. Chapter 8. Designing concurrent code
    1. 8.1. Techniques for dividing work between threads
    2. 8.2. Factors affecting the performance of concurrent code
    3. 8.3. Designing data structures for multithreaded performance
    4. 8.4. Additional considerations when designing for concurrency
    5. 8.5. Designing concurrent code in practice
    6. Summary
  18. Chapter 9. Advanced thread management
    1. 9.1. Thread pools
    2. 9.2. Interrupting threads
    3. Summary
  19. Chapter 10. Parallel algorithms
    1. 10.1. Parallelizing the standard library algorithms
    2. 10.2. Execution policies
    3. 10.3. The parallel algorithms from the C++ Standard Library
    4. Summary
  20. Chapter 11. Testing and debugging multithreaded applications
    1. 11.1. Types of concurrency-related bugs
    2. 11.2. Techniques for locating concurrency-related bugs
    3. Summary
  21. Appendix A. Brief reference for some C++11 language features
    1. A.1. Rvalue references
    2. A.2. Deleted functions
    3. A.3. Defaulted functions
    4. A.4. constexpr functions
    5. A.5. Lambda functions
    6. A.6. Variadic templates
    7. A.7. Automatically deducing the type of a variable
    8. A.8. Thread-local variables
    9. A.9. Class Template Argument Deduction
    10. Summary
  22. Appendix B. Brief comparison of concurrency libraries
  23. Appendix C. A message-passing framework and complete ATM example
  24. Appendix D. C++ Thread Library reference
    1. D.1. The <chrono> header
    2. D.2. <condition_variable> header
    3. D.3. <atomic> header
    4. D.4. <future> header
    5. D.5. <mutex> header
    6. D.6. <ratio> header
    7. D.7. <thread> header
  25. Index
  26. List of Figures
  27. List of Tables
  28. List of Listings

Product Information

  • Title: C++ Concurrency in Action, Second Edition
  • Author(s): Anthony Williams
  • Release date: February 2019
  • Publisher(s): Manning Publications
  • ISBN: 9781617294693