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
43
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
90
State Machines and How they Shape Mobile Architectures
rygelouv
1
84
Feature Flags for Mobile Development
rygelouv
0
150
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
59
Kotlin "by" Delegation
rygelouv
0
62
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
200
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
110
Other Decks in Programming
See All in Programming
色々なIaCツールを実際に触って比較してみる
iriikeita
0
310
デプロイを任されたので、教わった通りにデプロイしたら障害になった件 ~俺のやらかしを越えてゆけ~
techouse
53
33k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
180
推し活としてのrails new/oshikatsu_ha_iizo
sakahukamaki
3
2k
EventSourcingの理想と現実
wenas
6
2.2k
CSC509 Lecture 08
javiergs
PRO
0
110
PHP でアセンブリ言語のように書く技術
memory1994
PRO
1
160
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
8
4.9k
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
現場で役立つモデリング 超入門
masuda220
PRO
14
3.1k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.2k
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Docker and Python
trallard
40
3.1k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Automating Front-end Workflow
addyosmani
1366
200k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
The Cult of Friendly URLs
andyhume
78
6k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Producing Creativity
orderedlist
PRO
341
39k
Why Our Code Smells
bkeepers
PRO
334
57k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
27
2k
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