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
70
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
49
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
59
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
250
State Machines and How they Shape Mobile Architectures
rygelouv
0
260
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
160
Other Decks in Programming
See All in Programming
OSもどきOS
arkw
0
450
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
290
New "Type" system on PicoRuby
pocke
1
470
タクシーアプリ『GO』の バックエンド開発のおける AI利活用と若者のすべて
pyama86
3
1.9k
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
340
Oxcを導入して開発体験が向上した話
yug1224
4
290
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
270
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.5k
さぁV100、メモリをお食べ・・・
nilpe
0
130
プラグインで拡張される Context をtype-safe にする難しさと設計判断
kazupon
2
590
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
Featured
See All Featured
HDC tutorial
michielstock
2
690
Designing Experiences People Love
moore
143
24k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
380
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
380
WENDY [Excerpt]
tessaabrams
11
38k
Mobile First: as difficult as doing things right
swwweet
225
10k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
400
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
360
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
160
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
350
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