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
59
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
Leading Beyond Titles: Mobile Engineering Leadership from Both Sides of the Table
rygelouv
0
12
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
35
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
210
State Machines and How they Shape Mobile Architectures
rygelouv
0
210
Feature Flags for Mobile Development
rygelouv
0
220
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
140
Kotlin "by" Delegation
rygelouv
0
99
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
CSC307 Lecture 04
javiergs
PRO
0
640
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
220
ゆくKotlin くるRust
exoego
1
210
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
500
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
370
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
530
Basic Architectures
denyspoltorak
0
380
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
390
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.6k
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.5k
AgentCoreとHuman in the Loop
har1101
5
190
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
120
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Six Lessons from altMBA
skipperchong
29
4.1k
Raft: Consensus for Rubyists
vanstee
141
7.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
2
180
Art, The Web, and Tiny UX
lynnandtonic
304
21k
Paper Plane (Part 1)
katiecoart
PRO
0
3.2k
Being A Developer After 40
akosma
91
590k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
140
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.2k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
280
My Coaching Mixtape
mlcsv
0
28
Mind Mapping
helmedeiros
PRO
0
51
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