$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin Coroutines
Search
Rygel Louv
November 14, 2020
Programming
0
57
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
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
26
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
190
State Machines and How they Shape Mobile Architectures
rygelouv
0
200
Feature Flags for Mobile Development
rygelouv
0
210
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
120
Kotlin "by" Delegation
rygelouv
0
94
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
ハイパーメディア駆動アプリケーションとIslandアーキテクチャ: htmxによるWebアプリケーション開発と動的UIの局所的適用
nowaki28
0
420
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
120
チームをチームにするEM
hitode909
0
330
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
820
Cell-Based Architecture
larchanjo
0
120
AWS CDKの推しポイントN選
akihisaikeda
1
240
AIの誤りが許されない業務システムにおいて“信頼されるAI” を目指す / building-trusted-ai-systems
yuya4
6
3.4k
これならできる!個人開発のすゝめ
tinykitten
PRO
0
100
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
330
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
3
720
ID管理機能開発の裏側 高速にSaaS連携を実現したチームのAI活用編
atzzcokek
0
230
ZOZOにおけるAI活用の現在 ~モバイルアプリ開発でのAI活用状況と事例~
zozotech
PRO
8
5.6k
Featured
See All Featured
BBQ
matthewcrist
89
9.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Statistics for Hackers
jakevdp
799
230k
How STYLIGHT went responsive
nonsquared
100
6k
GitHub's CSS Performance
jonrohan
1032
470k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
34k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Speed Design
sergeychernyshev
33
1.4k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.6k
Why Our Code Smells
bkeepers
PRO
340
57k
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