“Introduction to C++ Coroutines"
summary
Proposal adds stackless coroutines to C++ that suspend and resume with no required overhead, claiming scalability to billions and suspend/resume cost comparable to a function call. Implementation shows a resumable type built from a compiler-generated frame plus a promise object, using await_ready/await_suspend/await_resume to control suspension, suspend_always/suspend_never for immediate or deferred suspend behavior, and a coroutine_handle to resume or destroy. Worked examples include converting sync TCP reads to co_await-based async, making std::future awaitable via a future_awaiter (uses then/get), and a generator via co_yield.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 0:29Proposal
- 1:09Motivation
- 1:40Demonstration
- 6:24Basics
- 17:30Coroutine Example
- 18:29Coroutine Handle Type
- 19:22Coroutine Promise Type
- 20:25Coroutine Structure
- 21:01Resumable Coroutine
- 22:47Questions
- 33:42Future
- 39:53Yield
- 42:56Summary
- 47:56Overhead
- 50:26Return Type Deduction
related talks
01h 01mUnderstanding C++ Coroutines by Example, Part 1
48m“Coroutines: what can't they do?”
01h 16mC++ Feature Coroutines, Beginner Friendly
58m“C++ Coroutines - a negative overhead abstraction"
01h 06mC++ Coroutines from scratch
01h 26mC++ Coroutines - Don’t Try This at Home
52mCoroutines: C++ vs Rust
01h 05m“Concurrency, Parallelism and Coroutines”
