Talk

The C++20 synchronization library

  • In English
Presentation pdf

In the decade since C++11 shipped, the hardware landscape has changed drastically. 10 years ago, we were still in the early stages of the concurrent processing revolution; 2 to 4 hardware threads were common and more than 10 was "many". Our tolerance for synchronization latency was greater; we were willing to pay microseconds and milliseconds.

Today, dozens and hundreds of threads are common, and "many" means hundreds of thousands. Concurrent applications are plagued by contention challenges that were unimaginable a decade ago. With the traditional tools we have today, programmers often have to choose between unacceptable contention and unacceptable high latency when synchronizing between threads.

The C++20 synchronization library brings solutions — new lightweight synchronization primitives that can efficiently marshall hundreds of thousands of threads:

  • std::atomic::wait/std::atomic::notify_*: Efficient atomic waiting.
  • std::atomic_ref: Atomic operations on non-std::atomic objects.
  • std::counting_semaphore: Lightweight access coordination.
  • std::latch and std::barrier: Marshalling groups of threads.

In this example-oriented talk, you'll learn how and when to use these new tools to build scalable, modern C++ applications that can run in parallel on virtually any hardware, from embedded controllers to server CPUs to modern GPUs.

  • #c++20
  • #synchronization

Speakers

Talks