Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin Coroutines
Search
Rygel Louv
November 14, 2020
Programming
0
53
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
2
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
150
State Machines and How they Shape Mobile Architectures
rygelouv
0
150
Feature Flags for Mobile Development
rygelouv
0
190
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
100
Kotlin "by" Delegation
rygelouv
0
76
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
220
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
130
Other Decks in Programming
See All in Programming
あまり知られていない MCP 仕様たち / MCP specifications that aren’t widely known
ktr_0731
0
220
あのころの iPod を どうにか再生させたい
orumin
0
140
Vibe Codingの幻想を超えて-生成AIを現場で使えるようにするまでの泥臭い話.ai
fumiyakume
21
10k
PHPカンファレンス関西2025 基調講演
sugimotokei
6
1.1k
Understanding Kotlin Multiplatform
l2hyunwoo
0
250
リッチエディターを安全に開発・運用するために
unachang113
1
350
管你要 trace 什麼、bpftrace 用下去就對了 — COSCUP 2025
shunghsiyu
0
190
令和最新版手のひらコンピュータ
koba789
2
800
Bedrock AgentCore ObservabilityによるAIエージェントの運用
licux
8
560
マイコンでもRustのtestがしたい その2/KernelVM Tokyo 18
tnishinaga
0
110
AIのメモリー
watany
12
1.3k
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
410
Featured
See All Featured
Become a Pro
speakerdeck
PRO
29
5.5k
Typedesign – Prime Four
hannesfritz
42
2.7k
A designer walks into a library…
pauljervisheath
207
24k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.5k
Designing for Performance
lara
610
69k
Balancing Empowerment & Direction
lara
1
530
Designing for humans not robots
tammielis
253
25k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
880
Done Done
chrislema
185
16k
How to Think Like a Performance Engineer
csswizardry
25
1.8k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
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