Multithreading in C++20: A Beginner's Guide to Concurrency

Added:

Choosing Concurrency Model
Managing Threads with Jthread
Synchronization with Latches and Barriers
Transferring Data with Futures and Promises
Protecting Data with Mutexes
Waiting for Data with Condition Variables
Advanced Synchronization & Q&A

Choosing Concurrency Model

0:01
Playing Section
  • 1

    Determines concurrency goals: scalability or separation of concerns.

  • 2

    Scalability limited by serial code fraction according to Amdahl's Law.

  • 3

    Start with parallel algorithms, then progress to more complex tools.

Proficiency in basic C++ syntax, object-oriented programming, and fundamental memory management concepts.
Familiarity with the modern C++ Standard Template Library (STL), particularly containers, algorithms, and basic smart pointers.
A conceptual understanding of Operating System fundamentals, specifically the distinction between a process and a thread, and how context switching works.
Deep dive into advanced C++20 coordination primitives such as std::latch, std::barrier, and std::counting_semaphore.
Exploration of lock-free programming, atomic operations (std::atomic), and the complexities of the C++ memory model and memory ordering.
Implementation and design of industry-standard concurrent architectures, such as custom Thread Pools and lock-free data structures.
Introduction to C++20 Coroutines for asynchronous, non-blocking I/O and cooperative multitasking.
93.2K views2Klikes1:06:45@CppConOriginal Release: 2022-12-06

C++20 provides a comprehensive threading model where developers should prioritize high-level abstractions like parallel algorithms, thread pools, and std::jthread with stop tokens for managing background tasks, followed by synchronization primitives such as latches, barriers, and futures, and only resort to mutexes, condition variables, and atomics when necessary, following a hierarchy that prioritizes correctness and ease of use over raw performance.