Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin Coroutines
Search
Rygel Louv
November 14, 2020
Programming
0
57
Kotlin Coroutines
Introduction to Kotlin Coroutines. We went through the basic concepts of Coroutines.
Rygel Louv
November 14, 2020
Tweet
Share
More Decks by Rygel Louv
See All by Rygel Louv
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
26
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
190
State Machines and How they Shape Mobile Architectures
rygelouv
0
200
Feature Flags for Mobile Development
rygelouv
0
210
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
120
Kotlin "by" Delegation
rygelouv
0
94
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
240
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
140
Other Decks in Programming
See All in Programming
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
110
AWS CDKの推しポイントN選
akihisaikeda
1
240
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
320
愛される翻訳の秘訣
kishikawakatsumi
2
320
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
240
AIエージェントを活かすPM術 AI駆動開発の現場から
gyuta
0
400
FluorTracer / RayTracingCamp11
kugimasa
0
230
生成AIを利用するだけでなく、投資できる組織へ
pospome
1
320
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
380
Github Copilotのチャット履歴ビューワーを作りました~WPF、dotnet10もあるよ~ #clrh111
katsuyuzu
0
110
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.5k
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
9
1.1k
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.7k
The Cost Of JavaScript in 2023
addyosmani
55
9.3k
A designer walks into a library…
pauljervisheath
210
24k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Six Lessons from altMBA
skipperchong
29
4.1k
Designing for Performance
lara
610
69k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Side Projects
sachag
455
43k
Transcript
Kotlin Coroutines Rygel Louv Dakar Ruby Brigade.
2019 Rygel Louv Software engineer
- Simplifying asynchronous programming - Write async code that looks
like sync code Coroutines: what problem do they solve ? P . 3
Synchronous blocking code P . 3
Synchronous blocking code P . 3
Async code using a callback P . 3
Callback Hell P . 3
Coroutines are the best of both worlds P . 3
Coroutines create a callback under the hood called Continuation P
. 3 Callback
State Machine and Continuation Passing Style P . 3
What is a coroutine ? P . 3 - Not
a thread - Takes a piece of code and run it in a thread - Lightweight thread
- Context switching: withContext - Dispatchers Coroutines concepts P .
3
- Dispatcher.Main: Main thread - Dispatcher.IO: Network and disk -
Dispatcher.Default: CPU (heavy computation) Coroutines dispatchers P . 3
- Canceling coroutine execution - Following a Lifecycle - Informing
components when Exception happens Coroutines concepts: Structured concurrency P . 3 Avoid memory leaks
- Keep track of coroutines - Ability to cancel them
- Is notified of failures Structure concurrency: Scopes P . 3
Coroutine scope: launching coroutines P . 3
P . 3 Coroutine scope: launching coroutines
P . 3 Coroutine scope: launching coroutines Parent Child Scope
will get all exceptions thrown by this function
- Cancels all coroutines - Can not start more coroutines
Scopes: cancelation P . 3
Suspend function in a coroutine P . 3
- When a child fails, the scope get notified -
Then the scope cancel itself and cancel all children Scopes exception handling: Job P . 3
- The failure of one child does not affect other
children - When the scope get notified of a failure, nothing happens Scopes exception handling: SupervisorJob P . 3
Creating coroutines P . 3
Creating coroutines: Launch P . 3 - Creates a new
coroutine - Fire and forget
Creating coroutines: Async P . 3 - Creates a new
coroutine - Returns a value Deferred == Promise/Future
P . 3
Cancellation requires co-operation P . 3
Cancellation require co-operation P . 3 - Check if coroutine
is Active
Next on coroutines P . 3 - Dive deeper in
Continuation Passing Style - More on co-operation - Channels - Flows
P . 27 THANK YOU