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
80
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
62
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
72
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
280
State Machines and How they Shape Mobile Architectures
rygelouv
0
280
Feature Flags for Mobile Development
rygelouv
0
260
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
170
Kotlin "by" Delegation
rygelouv
0
130
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
270
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
170
Other Decks in Programming
See All in Programming
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
280
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
400
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
770
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
560
Loosening the Reins: Go Generics Get More Flexible
kuro_kurorrr
0
360
仕様駆動開発の消費期限
watany
20
9.2k
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
140
Can LLMs Replicate 4 Years of Compose Migration? Exploring the boundaries of automation with 279 XML files from a real product
makun
0
110
T3DD26: From RAGs to Riches
martinhelmich
0
130
Hono + Inertia + React で LP を構築した話
oukayuka
2
190
いまどきの Codex で開発する visionOS アプリの開発スタイルについて
karad
0
170
「人を評価する AI」の設計と実装
ryoyanara
0
280
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
6.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
700
How STYLIGHT went responsive
nonsquared
100
6.3k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Deep Space Network (abreviated)
tonyrice
0
280
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
How to train your dragon (web standard)
notwaldorf
97
6.8k
Raft: Consensus for Rubyists
vanstee
141
7.7k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
57k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
310
New Earth Scene 8
popppiees
3
2.5k
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