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
54
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
15
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
160
State Machines and How they Shape Mobile Architectures
rygelouv
0
190
Feature Flags for Mobile Development
rygelouv
0
200
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
110
Kotlin "by" Delegation
rygelouv
0
82
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
230
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
130
Other Decks in Programming
See All in Programming
CSC509 Lecture 03
javiergs
PRO
0
320
Web Components で実現する Hotwire とフロントエンドフレームワークの橋渡し / Bridging with Web Components
da1chi
2
1.5k
クラシルを支える技術と組織
rakutek
0
190
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1k
Current States of Java Web Frameworks at JCConf 2025
kishida
0
560
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1k
Serena MCPのすすめ
wadakatu
4
850
WebエンジニアがSwiftをブラウザで動かすプレイグラウンドを作ってみた
ohmori_yusuke
0
170
defer f()とdefer fの挙動を 誤解していた話
kogamochiduki
2
160
CSC305 Lecture 01
javiergs
PRO
1
380
メモリ不足との戦い〜大量データを扱うアプリでの実践例〜
kwzr
1
700
議事録の要点整理を自動化! サーバレス Bot 構築術
penpeen
3
1.6k
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
Code Reviewing Like a Champion
maltzj
525
40k
A Modern Web Designer's Workflow
chriscoyier
697
190k
Documentation Writing (for coders)
carmenintech
75
5k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Unsuck your backbone
ammeep
671
58k
Thoughts on Productivity
jonyablonski
70
4.8k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
188
55k
Java REST API Framework Comparison - PWX 2021
mraible
33
8.8k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
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