Why use coroutines for asynchronous applications
summary
Claims that C++20 coroutines let you write reactive, non‑blocking applications in a synchronous style and that the compiler hides complex control flow. Examples compare synchronous, callback‑style async and coroutine versions using co_await/co_return and async_task, with implementations on Boost.Asio Qt5 gRPC ROS2. Real code runs on Windows 10/11 and Ubuntu 22.04/24.04; one example suspends and resumes ~10,000 times. Result: fewer split functions and callbacks, single‑threaded cooperative multitasking that actually works.
AI-written summary · about
chapters (18)
- 0:00Coroutines for async apps
- 1:07Goals of coroutines in async
- 5:21Speaker’s background and motivation for coroutines
- 8:15Coroutine concepts overview
- 18:09Sync vs async models
- 23:48Async programming styles
- 28:01Low-level I/O with coroutines
- 32:39Remote method invocation
- 34:49Protocol stacks example
- 40:19Sequential remote calls
- 44:10Parallel remote calls
- 46:41Nested loops in async
- 49:35Coroutines beyond async
- 54:07Thread alternatives in embedded
- 57:00Python for pipetting machines
- 58:03Completion handling thread
- 1:00:30gRPC with coroutines
- 1:03:19Summary
related talks
45mAsynchrony and Coroutines
47mC++ coroutines and Qt
58mAn Introduction to C++ Coroutines
55mC++20 coroutines as an API principle
01h 02mC++20’s Coroutines for Beginners
53mC++ Coroutines and Structured Concurrency in Practice
01h 02mTaro: Task Graph-Based Asynchronous Programming Using C++ Coroutine
57m[filtered] Asynchronous C++ Programming
