Structured Concurrency in C++: A Hands-On Workshop

Mateusz Pusz

⏱ 2-day-workshop-online
beginner
intermediate
advanced
09:00-18:00, Saturday, 29th - Sunday, 30th March 2025
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 std::execution framework, also called Senders/Receivers, which will arrive as a part of C++26. The reference implementation of this 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.

What You Will Learn?

  • Understand what structured concurrency is and how it helps write thread-safe code without the need for additional synchronization.
  • A detailed discussion of coroutine machinery and its suspend and customization points.
  • How to implement synchronous and asynchronous tasks using coroutines.
  • How to build a complex asynchronous pipeline with schedulers, senders, and receivers in a few lines of code.
  • Practical usage of all the asynchronous algorithms provided by the std::execution framework.

Workshop Structure

  • 30% lecture
  • 70% hands-on coding

Experience required

  • Recent working experience with writing simple C++ templates

Environment

  • A laptop with a web browser and access to the Internet
  • All hands-on exercises will be implemented using Compiler Explorer

Outline

  1. Asynchronous Programming with Coroutines

  2. Coroutine keywords, restrictions, suspend points

  3. Coroutine return type
  4. std::coroutine_traits
  5. Coroutine promise interface
  6. std::coroutine_handle
  7. Awaiters and Awaitables
  8. Symmetric Control Transfer
  9. C++ exceptions support
  10. Eager and Lazy Tasks
  11. async with coroutines
  12. sync_await

  13. Structured Concurrency with Senders and Receivers

  14. Motivation

  15. The structure of an asynchronous processing pipeline
  16. Data parallelism with senders
  17. Cancellation support
  18. Transferring the work
  19. Sender factories
  20. Sender adaptors
  21. Sender consumers
  22. Implementing an asynchronous algorithm
  23. Sender/Receivers and Coroutines
🏷 structured concurrency
🏷 coroutines
🏷 task
🏷 generator
🏷 senders/receivers
🏷 parallelism
🏷 design

Mateusz Pusz

A software architect, principal engineer, and security champion with over 20 years of experience designing, writing, and maintaining C++ code for fun and living. A trainer with over 10 years of C++ teaching experience, consultant, conference speaker, and evangelist. His main areas of interest and expertise are Modern C++, code performance, low latency, safety, and maintainability.

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, which provides dedicated C++ trainings and consulting services to corporations worldwide.

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.