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
55
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
19
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
170
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
84
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
開発組織の戦略的な役割と 設計スキル向上の効果
masuda220
PRO
8
1.2k
品質ワークショップをやってみた
nealle
0
620
Cursorハンズオン実践!
eltociear
2
1.2k
20251016_Rails News ~Rails 8.1の足音を聴く~
morimorihoge
2
670
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
420
XP, Testing and ninja testing ZOZ5
m_seki
3
810
テーブル定義書の構造化抽出して、生成AIでDWH分析を試してみた / devio2025tokyo
kasacchiful
0
270
React Nativeならぬ"Vue Native"が実現するかも?_新世代マルチプラットフォーム開発フレームワークのLynxとLynxのVue.js対応を追ってみよう_Vue Lynx
yut0naga1_fa
1
150
Catch Up: Go Style Guide Update
andpad
0
240
AIと人間の共創開発!OSSで試行錯誤した開発スタイル
mae616
2
790
バッチ処理を「状態の記録」から「事実の記録」へ
panda728
PRO
0
190
Writing Better Go: Lessons from 10 Code Reviews
konradreiche
3
6k
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Six Lessons from altMBA
skipperchong
29
4k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.7k
Building a Scalable Design System with Sketch
lauravandoore
463
33k
Why Our Code Smells
bkeepers
PRO
340
57k
Building Better People: How to give real-time feedback that sticks.
wjessup
369
20k
Site-Speed That Sticks
csswizardry
13
920
Mobile First: as difficult as doing things right
swwweet
225
10k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
10
880
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
930
Producing Creativity
orderedlist
PRO
347
40k
How to Ace a Technical Interview
jacobian
280
24k
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