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
70
0
Share
Kotlin Coroutines
Introduction to Kotlin Coroutines. We went through the basic concepts of Coroutines.
Rygel Louv
November 14, 2020
More Decks by Rygel Louv
See All by Rygel Louv
Leading Beyond Titles: Mobile Engineering Leadership from Both Sides of the Table
rygelouv
0
47
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
59
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
250
State Machines and How they Shape Mobile Architectures
rygelouv
0
250
Feature Flags for Mobile Development
rygelouv
0
240
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
160
Kotlin "by" Delegation
rygelouv
0
120
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
260
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
160
Other Decks in Programming
See All in Programming
Oxlintはいかにしてtsgolintのlint ruleを呼び出しているのか
syumai
2
760
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1k
Modding RubyKaigi for Myself
yui_knk
0
490
Moments When Things Go Wrong
aurimas
3
120
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
300
ECR拡張スキャンでSBOMを収集して サプライチェーン攻撃の影響調査を 爆速で終わらせてみた
akihisaikeda
2
200
Zod v4 Codec でスキーマに型変換を埋め込む REST API 設計 #TSKaigi2026
ryutaro_yako
0
150
分析エージェント精度向上における データアナリストの役割
oura_shoya
0
120
oxlintはeslint/typescript-eslintを置き換えられるのか
shomafujita
2
250
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
240
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
120
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
330
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
390
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
250
Six Lessons from altMBA
skipperchong
29
4.2k
Site-Speed That Sticks
csswizardry
13
1.2k
RailsConf 2023
tenderlove
30
1.4k
Fireside Chat
paigeccino
42
3.9k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
150
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
510
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
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