How to start using coroutines
summary
C++20 coroutines are usable now but require plumbing: GCC 10, MSVC recent, Clang 8 (experimental) support the three keywords co_await/co_yield/co_return. Each coroutine return type must provide a promise type requires get_return_object initial_suspend final_suspend return_value unhandled_exception, awaiters need three methods, and frames live on the heap so destruction and destroy must be handled. A tiny library implements task, sync_wait and when_all, and a single‑threaded scheduler running three coroutines works, but integration, sync APIs and multithreading primitives remain manual work.
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:28Plan
- 1:43Motivation
- 3:38Theory
- 4:25Steps of invocation
- 5:38Promise type
- 8:22Taskind
- 25:00Summary
- 25:36Call a protein
- 30:51Recap
- 31:20SyncWeight
- 32:51Conclusion
- 33:58Rewriting the code
- 37:12Why it doesnt work
- 40:31How to use it
related talks
01h 31mC++ Coroutines Demystified
01h 27mManage Asynchronous Control Flow With C++ Coroutines
01h 26mC++ Coroutines - Don’t Try This at Home
01h 23mImplementing a C++ Coroutine Task from Scratch
01h 14mHow to Use C++20 Coroutines for Networking
57mCoroutine Intuition in C++
52mCoroutines: C++ vs Rust
01h 05mCoroutines: C++ vs Rust
