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
48
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
130
State Machines and How they Shape Mobile Architectures
rygelouv
0
120
Feature Flags for Mobile Development
rygelouv
0
180
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
85
Kotlin "by" Delegation
rygelouv
0
67
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
210
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
120
Other Decks in Programming
See All in Programming
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
390
The Weight of Data: Rethinking Cloud-Native Systems for the Age of AI
hollycummins
0
270
Chrome Extension Techniques from Hell
moznion
1
160
S3静的ホスティング+Next.js静的エクスポート で格安webアプリ構築
iharuoru
0
220
Memory API : Patterns, Performance et Cas d'Utilisation
josepaumard
0
110
Defying Front-End Inertia: Inertia.js on Rails
skryukov
0
460
データベースエンジニアの仕事を楽にする。PgAssistantの紹介
nnaka2992
9
4.5k
gen_statem - OTP's Unsung Hero
whatyouhide
1
190
リストビュー画面UX改善の振り返り
splcywolf
0
130
Unlock the Potential of Swift Code Generation
rockname
0
240
MCP調べてみました! / Exploring MCP
uhzz
2
2.2k
Code smarter, not harder - How AI Coding Tools Boost Your Productivity | Webinar 2025
danielsogl
0
120
Featured
See All Featured
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
GitHub's CSS Performance
jonrohan
1030
460k
Designing for humans not robots
tammielis
252
25k
What's in a price? How to price your products and services
michaelherold
245
12k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.6k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
A designer walks into a library…
pauljervisheath
205
24k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
227
22k
How to Think Like a Performance Engineer
csswizardry
23
1.5k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Docker and Python
trallard
44
3.3k
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