Kotlin Coroutines: Design and Implementation
summary
Kotlin implements asymmetrical, stackless coroutines that compile suspend functions into continuations and state machines, returning COROUTINE_SUSPENDED at suspension points. The runtime exposes three low-level intrinsics (createCoroutineUnintercepted, startCoroutineUninterceptedOrReturn, suspendCoroutineUninterceptedOrReturn) plus interceptor-based dispatch so coroutines run on event loops, executors, or thread pools. Adapters convert callbacks, CompletableFuture-style promises and channels; generators are built on coroutines. Structured concurrency is supported to cancel sibling children on failure.
AI-written summary · about
chapters (19)
- 0:00Kotlin Coroutines: Design and implementation
- 0:55The story so far: callbacks
- 1:40The story so far: active/pipelined promises
- 2:26The story so far: async/await
- 3:05Honourable mention: green threads/fibers
- 3:36The story so far: coroutines
- 4:43Coroutine problems
- 5:45Kotlin coroutines: goals
- 6:40Kotlin coroutines: classification
- 7:03async/await family, but with a twist
- 7:41Gory implementation details
- 7:55The complete low-level API
- 8:22Compiling functions to continuations
- 9:03Interception
- 9:29Design evaluation
- 9:55The flexibility goal: different styles of computations
- 10:23The flexibility goal: generators
- 10:49Known limitations and future work
- 11:04Summing up
related talks
59mKotlin coroutines: new ways to do asynchronous programming
42mKotlin Coroutines: Beyond async/await
47mKotlin Coroutines Reloaded
47mKotlin Coroutines
43mCoroutines for Java Developers
38mCoroutines Internals: How The Sausage is Made
49mKotlin Coroutines
01h 03mUsing Kotlin Coroutines for Asynchronous and Concurrent Programming
