Video description
"This book should be on every C++ programmer’s desk. It’s clear, concise, and valuable."
Rob Green, Bowling Green State University
This bestseller has been updated and revised to cover all the latest changes to C++ 14 and 17! C++ Concurrency in Action, Second Edition teaches you everything you need to write robust and elegant multithreaded applications in C++17.
You choose C++ when your applications need to run fast. Well-designed concurrency makes them go even faster. C++ 17 delivers strong support for the multithreaded, multiprocessor programming required for fast graphic processing, machine learning, and other performance-sensitive tasks. This exceptional book/course unpacks the features, patterns, and best practices of production-grade C++ concurrency.
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.
Inside:- Full coverage of new C++ 17 features
- Starting and managing threads
- Synchronizing concurrent operations
- Designing concurrent code
- Debugging multithreaded applications
This book/course is written for intermediate C and C++ developers. No prior experience with concurrency required.
Anthony Williams has been an active member of the BSI C++ Panel since 2001 and is the developer of the just::thread Pro extensions to the C++ 11 thread library.
A thorough presentation of C++ concurrency capabilities.
Maurizio Tomasi, University of Milan
Highly recommended for programmers who want to further their knowledge of the latest C++ standard.
Frédéric Flayol, 4Pro Web C++
The guide contains snippets for everyday use in your own projects and to help take your concurrency C++ skills from the Padawan to the Jedi level.
Jura Shikin, IVI Technologies
NARRATED BY LISA FARINA AND DIANA GARDINER
Table of Contents
Ch 1. Hello, world of concurrency in C++!
What is concurrency?
Approaches to concurrency
Why use concurrency?
Concurrency and multithreading in C++
Efficiency in the C++ Thread Library
Getting started
Ch 2. Managing threads
Basic thread management
Waiting for a thread to complete
Passing arguments to a thread function
Transferring ownership of a thread
Choosing the number of threads at runtime
Identifying threads
Ch 3. Sharing data between threads
Problems with sharing data between threads
Protecting shared data with mutexes
Spotting race conditions inherent in interfaces Part 1
Spotting race conditions inherent in interfaces Part 2
Deadlock: the problem and a solution
Further guidelines for avoiding deadlock Part 1
Further guidelines for avoiding deadlock Part 2
Flexible locking with std::unique_lock
Locking at an appropriate granularity
Alternative facilities for protecting shared data
Protecting rarely updated data structures
Ch 4. Synchronizing concurrent operations
Waiting for an event or other condition
Building a thread-safe queue with condition variables
Waiting for one-off events with futures
Associating a task with a future
Saving an exception for the future
Waiting with a time limit
Time points
Using synchronization of operations to simplify code
Synchronizing operations with message passing
Continuation-style concurrency with the Concurrency TS
Chaining continuations
Waiting for the first future in a set with when_any
std::experimental::barrier: a basic barrier
Ch 5. The C++ memory model and operations on atomic types
Memory model basics
Atomic operations and types in C++
Operations on std::atomic_flag
Operations on std::atomic
Operations on standard atomic integral types
Free functions for atomic operations
Synchronizing operations and enforcing ordering
Memory ordering for atomic operations Part 1
Memory ordering for atomic operations Part 2
Memory ordering for atomic operations Part 3
Memory ordering for atomic operations Part 4
Release sequences and synchronizes-with
Ordering non-atomic operations
Ch 6. Designing lock-based concurrent data structures
What does it mean to design for concurrency?
Lock-based concurrent data structures
A thread-safe queue using locks and condition variables
A thread-safe queue using fine-grained locks and condition variables Part 1
A thread-safe queue using fine-grained locks and condition variables Part 2
A thread-safe queue using fine-grained locks and condition variables Part 3
Designing more complex lock-based data structures
Writing a thread-safe list using locks
Ch 7. Designing lock-free concurrent data structures
Definitions and consequences
Wait-free data structures
Examples of lock-free data structures
Stopping those pesky leaks: managing memory in lock-free data structures
Detecting nodes that can’t be reclaimed using hazard pointers Part 1
Detecting nodes that can’t be reclaimed using hazard pointers Part 2
Detecting nodes in use with reference counting
Applying the memory model to the lock-free stack
Writing a thread-safe queue without locks Part 1
Writing a thread-safe queue without locks Part 2
Writing a thread-safe queue without locks Part 3
Guidelines for writing lock-free data structures
Ch 8. Designing concurrent code
Techniques for dividing work between threads
Dividing data recursively
Dividing work by task type
Factors affecting the performance of concurrent code
False sharing
Designing data structures for multithreaded performance
Additional considerations when designing for concurrency
Scalability and Amdahl’s law
Designing concurrent code in practice
A parallel implementation of std::find
A parallel implementation of std::partial_sum Part 1
A parallel implementation of std::partial_sum Part 2
Ch 9. Advanced thread management
Thread pools
Waiting for tasks submitted to a thread pool
Tasks that wait for other tasks
Work stealing
Interrupting threads
Interrupting a condition variable wait
Handling interruptions
Ch 10. Parallel algorithms
Parallelizing the standard library algorithms
std::execution::parallel_policy
The parallel algorithms from the C++ Standard Library
Examples of using parallel algorithms
Ch 11. Testing and debugging multithreaded applications
Types of concurrency-related bugs
Techniques for locating concurrency-related bugs
Locating concurrency-related bugs by testing
Multithreaded testing techniques
Structuring multithreaded test code