Structured Concurrency in C++ 2024

Structured Concurrency in C++ is a two-day onsite training course with programming examples, taught by Mateusz Pusz. It is offered at the Gaylord Rockies from 09:00 to 17:00 Aurora time (MDT) on Saturday and Sunday, September 14th and 15th, 2024 (immediately prior to the conference). Lunch is included.

Course Description

Today, C++ software is increasingly asynchronous and parallel, a trend that is likely only to continue going forward. While the C++ Standard Library has a rich set of concurrency primitives and lower-level building blocks, we lack a standard framework for asynchrony and parallelism that C++ programmers desperately need.

Asynchrony and parallelism appear everywhere, from processor hardware interfaces to networking, to file I/O, to GUIs, to accelerators. Every C++ domain and every platform needs to deal with asynchrony and parallelism, from scientific computing to video games to financial services, from the smallest mobile devices to your laptop to GPUs in the world’s fastest supercomputer.

This training shows that concurrency is not only about the C++ Standard Library threading and synchronization low-level tools. During the workshop, you will learn how to write efficient, asynchronous, and highly concurrent code without the need for any manual synchronization between threads, leading to simpler code and faster runtimes. During the hands-on exercises, you will implement coroutine tools from scratch and create parallel processing pipelines with a new framework called Senders/Receivers proposed for standardization as a part of C++26. The Senders/Receivers framework is publicly available on GitHub so that it can be used in production immediately without the need to wait for the next C++ release.

During the workshop, we will work with the latest version of the compiler thanks to the Compiler Explorer, so no special environment preparation is needed.

Training Highlights

  • Understanding what structured concurrency is and how it helps in writing thread-safe code without the need for additional synchronization
  • A detailed discussion of coroutine machinery and its suspend and customization points
  • Introduction of schedulers, senders, and receivers abstractions, as well as an overview of all the asynchronous algorithms provided by the Sender/Receiver framework

Workshop Structure

  • 40% lecture
  • 60% hands-on coding

Prerequisites

A recent experience in implementing simple class templates is welcomed.

Course Topics

  • Asynchronous Programming with Coroutines
    • Coroutine keywords, restrictions, suspend points
    • Coroutine return type
    • std::coroutine_traits
    • Coroutine promise interface
    • std::coroutine_handle
    • Awaiters and Awaitables
    • Symmetric Control Transfer
    • C++ exceptions support
    • Eager and Lazy Tasks
    • async with coroutines
    • sync_await
  • Structured Concurrency with Senders and Receivers
    • Motivation
    • The structure of an asynchronous processing pipeline
    • Data parallelism with senders
    • Cancellation support
    • Transferring the work
    • Sender factories
    • Sender adaptors
    • Sender consumers
    • Implementing an asynchronous algorithm
    • Sender/Receivers and Coroutines

Register Here

Course Instructor

Mateusz Pusz

Mateusz Pusz is a software architect, principal engineer, and security champion with more than 15 years of experience in designing, writing and maintaining C++ code for fun and living. C++ consultant, trainer, conference speaker, and evangelist focused on Modern C++. His main areas of interest and expertise are code performance, low latency, stability, and security.

Mateusz worked at Intel for 13 years, and now he is a Principal Software Engineer and the head of the C++ Competency Center at EPAM Systems. He is also a founder of Train IT that provides dedicated C++ trainings and consultant services to corporations around the world.

Mateusz is a contributor and an active voting member of the ISO C++ Committee (WG21) where, together with the best C++ experts in the world, he shapes the future of the C++ language. He is also a co-chair of WG21 Study Group 14 (SG14) responsible for driving performance and low latency subjects in the Committee. In 2013 Mateusz won “Bench Games 2013” – worldwide competition in the C++ language knowledge.