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
36
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
20
State Machines and How they Shape Mobile Architectures
rygelouv
1
61
Feature Flags for Mobile Development
rygelouv
0
120
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
51
Kotlin "by" Delegation
rygelouv
0
54
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
190
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
110
Other Decks in Programming
See All in Programming
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
400
スキーマ駆動開発による品質とスピードの両立 - 私達は何故、スキーマを書くのか
kentaroutakeda
0
180
Introducing Kotlin Multiplatform in an existing mobile app - Workshop Edition | AndroidMakers Paris
prof18
0
140
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
140
Goのエラースタックトレースの歴史と今後
sonatard
10
1.7k
CREってこういうこと? 体験入社 - 提案資料 - / what-is-cre-trial-employment
shinden
1
410
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
490
Git Lint
bkuhlmann
4
760
Fast JSX: Don't clone props object #28768
yossydev
1
160
GitHub Copilotのススメ
marcy731
1
220
Amazon SQSコンシューマー疎結合への旅 - 出張! #DevelopersIO IT技術ブログの中の人が語る勉強会 #3
quiver
0
300
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
270
Featured
See All Featured
Done Done
chrislema
178
15k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
The Invisible Customer
myddelton
114
12k
Facilitating Awesome Meetings
lara
43
5.6k
Product Roadmaps are Hard
iamctodd
45
9.7k
Typedesign – Prime Four
hannesfritz
36
2.1k
Clear Off the Table
cherdarchuk
85
310k
Designing on Purpose - Digital PM Summit 2013
jponch
111
6.5k
GitHub's CSS Performance
jonrohan
1025
450k
The Illustrated Children's Guide to Kubernetes
chrisshort
32
46k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
33
6k
It's Worth the Effort
3n
180
27k
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