C++ Coroutines from scratch
summary
Shows a concrete migration from a lambda‑continuation loader to C++20 coroutines that replaces manual batching with coroutine suspension. Code uses a promise type, coroutine_handle and promise type, and custom awaiters to hold dependency state on the coroutine frame. A synthetic 10 ms per-file latency example loads 10 transitive objects, collapsing 10→3 round trips and cutting runtime from ~123ms→38ms. The loader is implemented over JSON deserialization and the coroutine version reduces allocations and simplifies lifetime handling.
AI-written summary · about
chapters (11)
- 0:00C++ coroutines intro
- 3:51Real-world problem scenario
- 9:10Naive object loading
- 15:51Performance bottlenecks
- 17:58Batch loading optimization
- 28:20Coroutine architecture
- 36:43Promise type methods
- 44:26Build task coroutines
- 53:24Final coroutine benefits
- 57:43Key differences from lambda-based approach
- 1:00:13C++20 generators & closing
related talks
41m(Don't) use coroutines for this
54mawait 2.0: Stackless Resumable Functions
01h 03mFrom Problem to Coroutine: Reducing I/O Latency
55mBehavioral Modeling in HW/SW Co-design Using C++ Coroutines
25mAsynchrony: Under the Hood
53mAsync sequences and algorithms to compose them
30mCracking the Concurrent Mode
45mBack to Front and Beyond
