Deciphering Coroutines - a visual approach
summary
Sustainable introduction to C++20 coroutines that builds a cheat sheet of diagrams and minimal working code, showing how the compiler creates the return object, how the promise type, awaitable (await_ready/await_suspend/await_resume) and coroutine_handle connect, how to pass data both directions, how co_yield maps to yield_value, and that coroutines are stackless with initial_suspend/final_suspend. Examples compile, demonstrate resume and destroy semantics, symmetric transfer, and allocator customization via operator new, so the mechanisms and practical patterns are visible and reproducible.
AI-written summary · about
chapters (45)
- 0:00Intro
- 2:50Agenda
- 3:38Disclaimer
- 4:20Basics
- 7:00Async
- 10:03Suspended execution
- 10:58Generator example
- 12:50Generator object
- 14:14Interface
- 14:49Return type
- 16:14Core routine
- 17:02Core routine example
- 24:03Print statement
- 25:04Pause function
- 25:16awaitable
- 28:05suspension
- 29:37quarantine
- 30:42suspend always
- 34:01cheat sheet
- 36:45awaitables
- 38:04resuming core routines
- 38:21resume example
- 39:09the problem
- 42:12first connection
- 42:36await suspend
- 42:55recap
- 44:06essential examples
- 44:22await
- 45:45for caller
- 46:08getanswer
- 46:23controlflow
- 46:36the other way
- 46:47the caller side
- 48:56the quarantine
- 49:09the await suspend
- 50:16return value
- 50:59yield
- 51:59yield value
- 53:10customer waitable
- 53:33symmetric transfer
- 54:27Symmetrical transfer
- 56:10Summary
- 56:35Learning the syntax
- 57:21Cheatsheet
- 58:00Questions
related talks
41m(Don't) use coroutines for this
54mawait 2.0: Stackless Resumable Functions
55mBehavioral Modeling in HW/SW Co-design Using C++ Coroutines
59mBuilding an Intuition for Composition
01h 03mFrom Problem to Coroutine: Reducing I/O Latency
25mAsynchrony: Under the Hood
01h 04mA Pattern Language for Expressing Concurrency in Cpp
01h 00mDesign Idioms from an Alternate Universe
