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
46
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
120
State Machines and How they Shape Mobile Architectures
rygelouv
0
110
Feature Flags for Mobile Development
rygelouv
0
170
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
76
Kotlin "by" Delegation
rygelouv
0
65
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
210
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
110
Other Decks in Programming
See All in Programming
sappoRo.R #12 初心者セッション
kosugitti
0
260
ML.NETで始める機械学習
ymd65536
0
110
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
740
『テスト書いた方が開発が早いじゃん』を解き明かす #phpcon_nagoya
o0h
PRO
2
290
SpringBoot3.4の構造化ログ #kanjava
irof
2
1k
時計仕掛けのCompose
mkeeda
1
300
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
110
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
ペアーズでの、Langfuseを中心とした評価ドリブンなリリースサイクルのご紹介
fukubaka0825
2
330
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
170
クリーンアーキテクチャから見る依存の向きの大切さ
shimabox
2
480
ARA Ansible for the teams
kksat
0
150
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Automating Front-end Workflow
addyosmani
1368
200k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
For a Future-Friendly Web
brad_frost
176
9.5k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Building Your Own Lightsaber
phodgson
104
6.2k
Become a Pro
speakerdeck
PRO
26
5.1k
Code Reviewing Like a Champion
maltzj
521
39k
RailsConf 2023
tenderlove
29
1k
The Cult of Friendly URLs
andyhume
78
6.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
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