Kotlin Coroutines Reloaded
summary
Kotlin rewrites coroutines to avoid rare synchronous callback recursion bugs by changing the suspend protocol: a call either returns the result or the COROUTINE_SUSPENDED token, implemented via a hidden CPS transformation and a compiler intrinsic suspendCoroutine plus tail-call forwarding. Continuations gain a CoroutineContext so dispatch and thread-affinity are pluggable; libraries provide channels, mutex, actors, runBlocking and Java Future adapters. Trade-offs: no JVM hacks for thread‑locals, imperfect stack traces on exceptions, and the feature remains experimental and opt‑in.
AI-written summary · about
chapters (26)
- 0:00Intro
- 1:44Async the Kotlin way (prototype)
- 2:37Suspending functions: use
- 2:53Suspending functions: declare (prototype)
- 3:27Suspending functions: implement (prototype)
- 4:41A problematic example
- 7:04stack unwind convention
- 7:14A solution (0)
- 8:55Call/declaration fidelity
- 12:15Tail suspension
- 13:12Abstraction
- 14:58Recap steps to solution
- 15:43The final touch: await extension
- 16:54Coroutine builders (prototype)
- 20:35Arbitrary suspending calls
- 23:16Stackless vs Stackful coroutines
- 27:04The problem with async
- 29:59Composability: evolved
- 31:35asyncul (prototype)
- 33:09The actual Continuation interface
- 35:59Thread confinement vs coroutines
- 38:20Stack traces in exceptions
- 40:54Library evolution: already there
- 43:23Library evolution: WIP
- 45:05A closing note on terminology
- 45:45Experimental status of coroutines
related talks
11mKotlin Coroutines: Design and Implementation
42mKotlin Coroutines: Beyond async/await
43mCoroutines for Java Developers
45mDeep Dive into Coroutines on JVM
38mCoroutines Internals: How The Sausage is Made
40mConcurrency made easy with Kotlin Coroutines
39mCoroutine Suspension Mechanics
38mKotlin coroutines
