Introduction to C++ Coroutines and gRPC and How to Write Coroutine Support Code
summary
Explains how to add coroutine support to gRPC by writing a custom promise type and an awaitable/awaiter that starts start_write, stores the coroutine_handle in the reactor, and resumes it from on_write_done; implements server-streaming send as a straightforward suspend/resume loop. Demonstrates this works with the gRPC reactor API, uses C++20 coroutines and Boost AIO as options, and claims the support is a few pages of code (scales to a few hundred lines) with examples and slides on GitHub.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:09Coroutines & gRPC background
- 5:49C++ coroutines basics
- 7:17Language support & return types
- 9:03Generators explained
- 11:30Task-based async
- 19:16gRPC introduction
- 20:40Sync vs reactor gRPC
- 26:35Coroutines for gRPC streaming
- 30:27Simplest coroutine support
- 38:14Promise type & transformations
- 40:41Simplest gRPC coroutine
- 45:14Sending responses with coroutines
- 50:55Implementing awaiters
- 54:06Summary & next steps
related talks
01h 14mHow to Use C++20 Coroutines for Networking
47mHow to start using coroutines
01h 31mC++ Coroutines Demystified
57mCoroutine Intuition in C++
01h 26mC++ Coroutines - Don’t Try This at Home
01h 27mManage Asynchronous Control Flow With C++ Coroutines
01h 23mImplementing a C++ Coroutine Task from Scratch
01h 16mC++ Coroutines From Scratch
