Coroutine Suspension Mechanics
summary
Explains that the Kotlin compiler rewrites every suspend function into a continuation‑passing signature (adds a continuation parameter) and generates a tiny class per suspend function that holds locals and a label integer; suspension points become n+1 states in a when dispatch, functions return either the real value or a special COROUTINE_SUSPENDED marker, and callbacks turn into suspendCancellableCoroutine + continuation.resumeWith. Notes inline suspend functions merge into the caller FSM, the Job holds a separate lifecycle FSM, and the result is predictable, heap‑small coroutines across JVM/ART.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:08Talk overview
- 3:37Coroutine suspension magic
- 7:17Kotlin state machines
- 9:47Direct vs continuation style
- 13:24Finite state machines
- 21:22Callbacks to coroutines
- 23:33State machines in practice
- 31:22Nested state machines
- 35:36Inline suspend functions
- 36:42Job state machine
- 37:04Closing








