$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin Coroutines
Search
Rygel Louv
November 14, 2020
Programming
0
57
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
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
26
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
190
State Machines and How they Shape Mobile Architectures
rygelouv
0
200
Feature Flags for Mobile Development
rygelouv
0
210
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
120
Kotlin "by" Delegation
rygelouv
0
94
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
240
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
140
Other Decks in Programming
See All in Programming
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
140
Developing static sites with Ruby
okuramasafumi
0
250
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.2k
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.2k
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
430
Integrating WordPress and Symfony
alexandresalome
0
140
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
210
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
200
AIコーディングエージェント(Manus)
kondai24
0
160
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
11
11k
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
38
25k
生成AIを利用するだけでなく、投資できる組織へ
pospome
0
240
Featured
See All Featured
Writing Fast Ruby
sferik
630
62k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
A designer walks into a library…
pauljervisheath
210
24k
Code Review Best Practice
trishagee
74
19k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Designing for humans not robots
tammielis
254
26k
Balancing Empowerment & Direction
lara
5
790
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.2k
Producing Creativity
orderedlist
PRO
348
40k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
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