C++ Coroutines From Scratch
summary
An object-deserialization pipeline gets rewritten from recursive, callback-heavy code into a coroutine-driven batch loader that drops 10 network round-trips to about 3 and cuts runtime from ~123 ms to ~36 ms (≈3x faster). It uses C++20 coroutines with promise types living in the coroutine frame, co_await/co_yield to suspend/resume, and a generator-style interface (std::generator planned in C++23). The code removes manual continuation lambdas and extra allocations but requires passing coroutine arguments by value to avoid dangling references.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:52Coroutines learning curve
- 6:03Quant library deserialization
- 11:55Depth-first deserialization
- 16:12Deserialization bottlenecks
- 18:47Breadth-first deserialization
- 31:11C++ coroutines
- 48:29Coroutines for deserialization
- 1:07:56std::generator and summary
related talks
01h 14mHow to Use C++20 Coroutines for Networking
01h 31mC++ Coroutines Demystified
01h 27mPowerful Data Processing Pipelines with C++20 Coroutines
01h 26mC++ Coroutines - Don’t Try This at Home
52mCoroutines are Qt: safer thread pools interactions
47mHow to start using coroutines
57mCoroutine Intuition in C++
52mCoroutines: C++ vs Rust
