A coroutine in C++ is an finite state machine that can be controlled and customized by the promise_type
.
Promise Type
A promise type is used to coordinate with coroutines. Unlike the return type, it resides in the coroutine frame and are usually accessed through a pointer (which can be returned by .promise()
of a coroutine handle)
Insights
Resources
- Introduction to C++ Coroutines Through a Thread Scheduling Demonstration
- Deciphering C++ Coroutines - A Diagrammatic Coroutine Cheat Sheet - Andreas Weis - CppCon 2022
- C++ Coroutine Intuition - Roi Barkan - CppNow 2023
- C++ Coroutines from Scratch by Andreas Fertig
- Coroutines C++ vs Rust
- Adventures in Thread-per-Core Async with Redpanda and Seastar by Travis Downs