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
52
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
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
140
State Machines and How they Shape Mobile Architectures
rygelouv
0
140
Feature Flags for Mobile Development
rygelouv
0
180
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
94
Kotlin "by" Delegation
rygelouv
0
72
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
220
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
120
Other Decks in Programming
See All in Programming
DroidKnights 2025 - 다양한 스크롤 뷰에서의 영상 재생
gaeun5744
3
300
Cursor AI Agentと伴走する アプリケーションの高速リプレイス
daisuketakeda
1
120
Using AI Tools Around Software Development
inouehi
0
1.2k
Cline指示通りに動かない? AI小説エージェントで学ぶ指示書の書き方と自動アップデートの仕組み
kamomeashizawa
1
560
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
130
統一感のある Go コードを生成 AI の力で手にいれる
otakakot
0
3k
LINEヤフー データグループ紹介
lycorp_recruit_jp
0
770
レガシーシステムの機能調査・開発におけるAI利活用
takuya_ohtonari
0
610
CursorはMCPを使った方が良いぞ
taigakono
0
150
Webからモバイルへ Vue.js × Capacitor 活用事例
naokihaba
0
740
Perplexity Slack Botを作ってAI活用を進めた話 / AI Engineering Summit プレイベント
n3xem
0
670
[初登壇@jAZUG]アプリ開発者が気になるGoogleCloud/Azure+wasm/wasi
asaringo
0
130
Featured
See All Featured
Building Adaptive Systems
keathley
43
2.6k
Designing for humans not robots
tammielis
253
25k
Git: the NoSQL Database
bkeepers
PRO
430
65k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
181
53k
How to Ace a Technical Interview
jacobian
277
23k
Rails Girls Zürich Keynote
gr2m
94
14k
Visualization
eitanlees
146
16k
Navigating Team Friction
lara
187
15k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Site-Speed That Sticks
csswizardry
10
650
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.4k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
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