Coroutines and Go
summary
Shows a concrete implementation of coroutines in Go using goroutines and channels as the transport, exposing a cororo package with resume/yield/cancel semantics, panic propagation and a cancel handshake so callers do not deadlock. Claims no added parallelism (only one coroutine runs at a time). Measurements: channel-based switches cost about 190 ns per switch, compiler fusion cuts that ~38% to ~118 ns, and a direct coroutine switch drops to 20 ns. The design works and handles panics and cancellation.
AI-written summary · about
chapters (12)
- 0:00Introduction to coroutines
- 1:34Defining subroutines
- 4:13Binary tree comparison example
- 6:05History of coroutines
- 9:21Coroutines in modern languages
- 12:38Classifying coroutines
- 16:44Coroutines in Go
- 18:57Coroutines vs threads
- 20:26Implementing coroutines in Go
- 24:02Robust coroutine features
- 27:56Runtime optimizations
- 29:15Conclusion and references
related talks
41mCoroutines explained by example
45mCoroutines: Kotlin Versus
52mCoroutines: C++ vs Rust
45mCoroutines explained
01h 21mC++ Coroutines at Scale - Implementation Choices at Google
44mCoroutines Party Tricks
01h 30mC++ Coroutines and Structured Concurrency in Practice
01h 04mcore.async: Concurrency without Callbacks
