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
60
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
Leading Beyond Titles: Mobile Engineering Leadership from Both Sides of the Table
rygelouv
0
22
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
36
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
210
State Machines and How they Shape Mobile Architectures
rygelouv
0
210
Feature Flags for Mobile Development
rygelouv
0
220
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
140
Kotlin "by" Delegation
rygelouv
0
100
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
250
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
140
Other Decks in Programming
See All in Programming
new(1.26) ← これすき / kamakura.go #8
utgwkk
0
1.5k
浮動小数の比較について
kishikawakatsumi
0
370
クライアントワークでSREをするということ。あるいは事業会社におけるSREと同じこと・違うこと
nnaka2992
1
300
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
3
1.3k
TipKitTips
ktcryomm
0
150
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
130
15年目のiOSアプリを1から作り直す技術
teakun
1
590
AI主導でFastAPIのWebサービスを作るときに 人間が構造化すべき境界線
okajun35
0
500
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
140
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
360
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
320
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
510
Featured
See All Featured
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
62
51k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.1k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
270
Building the Perfect Custom Keyboard
takai
2
710
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.3k
Skip the Path - Find Your Career Trail
mkilby
1
72
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
380
Building a Scalable Design System with Sketch
lauravandoore
463
34k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
130
How to Think Like a Performance Engineer
csswizardry
28
2.5k
Ruling the World: When Life Gets Gamed
codingconduct
0
160
Abbi's Birthday
coloredviolet
2
5.1k
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