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 aims to teach not only the C++ Standard Library threading and synchronization low-level tools but also provides an excellent introduction to structured concurrency with C++ Coroutines and a new framework called Senders/Receivers proposed for standardization as a part of C++26.
During the workshop, we will work with the latest compiler version thanks to the Compiler Explorer, so no special environment preparation is needed.
TRAINING HIGHLIGHTS
- Overview of the "old" concurrency facilities introduced from C++11 up to C++17
- Learning new concurrency facilities provided with C++20
- 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
TRAINING AGENDA
The following plan is an initial proposal for the training material. The final agenda is always created based on the individual pre-training analysis of the client's requirements and constraints.
- Concurrency in the C++ Standard Library
- Different kinds of concurrency
- Parallelism vs Concurrency
- Parallel algorithms
- Synchronized buffered ostreams
- std::thread
- std::jthread and std::stop_token
- Mutexes
- Structuring code for protecting shared data
- Locks
- Deadlocks
- Monitor design pattern
- std::call_once and std::once_flag
- std::condition_variable
- concurrent_queue
- Semaphores
- std::latch
- std::barrier
- Futures
- std::async
- std::packaged_task
- std::promise
- 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