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
68
0
Share
Kotlin Coroutines
Introduction to Kotlin Coroutines. We went through the basic concepts of Coroutines.
Rygel Louv
November 14, 2020
More Decks by Rygel Louv
See All by Rygel Louv
Leading Beyond Titles: Mobile Engineering Leadership from Both Sides of the Table
rygelouv
0
43
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
59
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
240
State Machines and How they Shape Mobile Architectures
rygelouv
0
240
Feature Flags for Mobile Development
rygelouv
0
240
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
160
Kotlin "by" Delegation
rygelouv
0
120
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
260
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
150
Other Decks in Programming
See All in Programming
Are We Really Coding 10× Faster with AI?
kohzas
0
200
Skillは並べた。動かなかった。契約で繋いだ。— 65個のSkillから、自走する開発サイクルへ
junholee
0
660
AIを導入する前にやるべきこと
negima
2
370
~ 秘伝のタレ化した『神スプシ』と戦う ~ 関数型パラダイムで壊れない仕組みへ
h0r15h0
1
120
Modding RubyKaigi for Myself
yui_knk
0
330
開発とはなにか、Essenceカーネルで見えるもの
ukin0k0
0
190
RailsTokyo 2026#4: AI様があれば、 Hotwireの弱点は消えるか?
naofumi
3
450
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
380
AI Agent と正しく分析するための環境作り
yoshyum
2
550
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
520
AgentCore Optimizationを始めよう!
licux
3
260
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
4
560
Featured
See All Featured
Accessibility Awareness
sabderemane
1
120
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
460
How Software Deployment tools have changed in the past 20 years
geshan
0
33k
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
800
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Navigating Weather and Climate Data
rabernat
0
190
Balancing Empowerment & Direction
lara
6
1.1k
We Are The Robots
honzajavorek
0
230
The SEO identity crisis: Don't let AI make you average
varn
0
470
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
370
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.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