Manage Asynchronous Control Flow With C++ Coroutines
summary
Shows how to implement an async/await-style Task type for C++20 coroutines by explicitly linking coroutine promises and handles, using symmetric transfer to swap call-stack frames, a resume-caller awaitable in final_suspend to wake the caller, and a simple scheduler registration to pump IO completions. Demonstrates initial_suspend to defer body execution, propagating execution context through promises, and a spawn_task pattern that returns the final result — a working approach that reconstructs nested async call stacks.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:11Coroutine basics recap
- 9:22Focus on async IO
- 13:31Coroutines vs green threads
- 22:24Stackless coroutine challenges
- 32:14Call stack mechanics
- 38:11Building call stacks
- 43:54Resuming outer coroutines
- 53:37Waking inner coroutines
- 1:01:03Execution context propagation
- 1:08:57Initial suspend and transfer
- 1:14:38Spawning coroutines
- 1:20:59Final result handling
- 1:23:33Coroutines as data
- 1:26:43Q&A
related talks
01h 23mImplementing a C++ Coroutine Task from Scratch
47mHow to start using coroutines
57mCoroutine Intuition in C++
01h 26mC++ Coroutines - Don’t Try This at Home
01h 05mCoroutines: C++ vs Rust
01h 14mHow to Use C++20 Coroutines for Networking
52mCoroutines: C++ vs Rust
01h 00mIntroduction to C++ Coroutines and gRPC and How to Write Coroutine Support Code
