developers, architects
2 days

Coroutines are one of the most significant language additions in C++20.

It is a powerful but also quite complex feature. It allows us to run many concurrent coroutines with no overhead. The coroutine framework is open-ended, meaning that library authors may develop coroutine libraries exposing various high-level semantics. Unfortunately, there is no coroutine support library in C++20. C++23 will only provide `std::generator`, and some more types are expected to come only with C++26. This is the reason why we not only need to understand the coroutine framework (both language and library parts) and how to use coroutine tools but also learn how to write such utilities by ourselves.

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.


  • Detailed discussion of coroutine machinery and its suspend and customization points
  • Understanding the differences between a coroutine return type, coroutine promise type, coroutine traits, coroutine handle, an awaiter, and an awaitable
  • Implementing synchronous and asynchronous tasks in eager and lazy ways and discussing the essential differences
  • "Teaching" some common and custom C++ types on how to become awaitables, and discussing the potential issues and solutions with different approaches
  • Developing custom generators and learning how to connect them to the C++ range adaptor objects processing pipeline
  • Learning how to deal with coroutines from regular functions like `main()`
  • Why and how to improve our implementations with the coroutine symmetric control transfer
  • Using C++20 concepts and constraints, ranges and views, and new concurrency tools in action


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.

  1. Coroutines
    1. Coroutine keywords, restrictions, suspend points
    2. Coroutine return type
    3. std::coroutine_traits
    4. Coroutine promise interface
    5. std::coroutine_handle
    6. Awaiters and Awaitables
    7. Symmetric Control Transfer
    8. C++ exceptions support
    9. Eager and Lazy Tasks
    10. async with coroutines
    11. sync_await
    12. Generators
    13. Custom allocator support
    14. Coroutine support libraries
developers, architects
2 days


Mateusz Pusz