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
43
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
91
State Machines and How they Shape Mobile Architectures
rygelouv
1
85
Feature Flags for Mobile Development
rygelouv
0
150
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
59
Kotlin "by" Delegation
rygelouv
0
62
Introduction to Type-Safe Builders: create a DSL in Kotlin
rygelouv
0
200
Annotation processing: generate code, eliminate boilerplate
rygelouv
0
110
Other Decks in Programming
See All in Programming
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
1
260
よくできたテンプレート言語として TypeScript + JSX を利用する試み / Using TypeScript + JSX outside of Web Frontend #TSKaigiKansai
izumin5210
6
1.7k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
950
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
130
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.8k
Quine, Polyglot, 良いコード
qnighy
4
650
ECS Service Connectのこれまでのアップデートと今後のRoadmapを見てみる
tkikuc
2
250
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
Remix on Hono on Cloudflare Workers
yusukebe
1
300
役立つログに取り組もう
irof
28
9.6k
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
459
33k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Designing Experiences People Love
moore
138
23k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Writing Fast Ruby
sferik
627
61k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Git: the NoSQL Database
bkeepers
PRO
427
64k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
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