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
86
State Machines and How they Shape Mobile Architectures
rygelouv
1
82
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
60
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
Securify_エンジニア採用資料
3shake
0
110
LangGraphでのHuman-in-the-Loopの実装
os1ma
3
1.1k
XStateでReactに秩序を与えたい
gizm000
0
740
watsonx.ai Dojo #2 生成AIを使ったアプリ開発入門編
oniak3ibm
PRO
0
240
KSPの導入・移行を前向きに検討しよう!
shxun6934
PRO
0
290
Pythonで改めて考える「クラス(class)」の使いどころ
os1ma
4
980
React + TextAliveでカッコいいLyric Applicatioinを作ろう!!
tosuri13
0
400
What you can do with Ruby on WebAssembly
kateinoigakukun
0
170
ドメイン駆動設計を実践するために必要なもの
bikisuke
4
330
The Shape of a Service Object
inem
0
530
unique パッケージから学ぶ interning と weak reference @ Asakusa.go#3
karamaru
2
820
マルチモジュールにおけるテスト最適化
fxwx23
0
210
Featured
See All Featured
Making Projects Easy
brettharned
113
5.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
354
29k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
23
1.7k
Why Our Code Smells
bkeepers
PRO
334
56k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
190
16k
The Cult of Friendly URLs
andyhume
76
6k
Music & Morning Musume
bryan
46
6k
Mobile First: as difficult as doing things right
swwweet
221
8.8k
Into the Great Unknown - MozCon
thekraken
29
1.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
158
15k
What the flash - Photography Introduction
edds
67
11k
Faster Mobile Websites
deanohume
304
30k
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