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
77
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
61
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
71
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
280
State Machines and How they Shape Mobile Architectures
rygelouv
0
280
Feature Flags for Mobile Development
rygelouv
0
250
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
170
Kotlin "by" Delegation
rygelouv
0
130
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
270
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
170
Other Decks in Programming
See All in Programming
Oxlintはいいぞ(続)
yug1224
1
270
まだ間に合う!今年の夏こそSchemeのマクロ展開器を完全理解!
omasanori
0
160
仕様駆動開発の消費期限
watany
20
8.8k
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
320
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
230
Flow は今どうなっているか
mizdra
PRO
0
660
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
30年振りにコンパイラの定数整数除算を改善した
herumi
3
540
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
710
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
110
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
220
What's New in Android 2026
veronikapj
0
270
Featured
See All Featured
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
500
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Claude Code のすすめ
schroneko
67
230k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Odyssey Design
rkendrick25
PRO
2
770
Designing for Performance
lara
611
70k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
260
A Tale of Four Properties
chriscoyier
163
24k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
250
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
390
The Curious Case for Waylosing
cassininazir
1
470
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