Coroutine Patterns: Problems and Solutions Using Coroutines in a Modern Codebase
Talkat CppCon 2023 · on Thursday, 2023-10-05· at 09:00· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard·
summary
Shows concrete coroutine pitfalls and fixes from a heavily coroutinized codebase using Folly: lazy tasks, executor propagation and sticky executors that avoid leaking scheduling, real lifetime bugs where member coroutines implicitly capture this, lambda and temporary-object lifetimes, and how unsafely using blocking waits leads to blocking_wait deadlocks. Recommends structured concurrency, ASan for hard cases, co_try and async scopes to capture exceptions, and an explicit async cleanup pattern for RAII where destructors cannot co_await.
AI-written summary · about
chapters (16)
- 0:00Intro
- 1:00Agenda
- 1:24Motivation
- 3:47Tasks and Executors
- 6:25Executor
- 8:32Lifetime
- 9:54Game
- 14:27Keeping objects alive
- 16:07Scheduling the background
- 17:29ASN scope
- 18:01Exceptions
- 19:39Cleanup
- 23:07Synchronization
- 24:35Mutexes
- 26:13Coroutine Locks
- 27:35Conclusion
related talks
53mC++ Coroutines and Structured Concurrency in Practice
45mAsynchrony and Coroutines
01h 02mC++20’s Coroutines for Beginners
55mC++20 coroutines as an API principle
01h 05mCoroutines: C++ vs Rust
01h 05mWhy use coroutines for asynchronous applications
57m[filtered] Asynchronous C++ Programming
52mBest Practices for Concurrency
