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
76
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
57
Model Context Protocol: Connecting AI Models to the Real World
rygelouv
0
70
Exploring Mobile Release Management: Strategies and Best Practices
rygelouv
0
270
State Machines and How they Shape Mobile Architectures
rygelouv
0
280
Feature Flags for Mobile Development
rygelouv
0
250
Build and Publish an Open Source Android Library for Fun and Non profit
rygelouv
1
160
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
5分で問診!Composer セキュリティ健康診断
codmoninc
0
970
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
320
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
570
数百円から始めるRuby電子工作
tarosay
0
140
【やさしく解説 設計編・中級 #6】良いアーキテクチャとは ~ 一本の登り道の、行き先 ~
panda728
PRO
0
210
Built Our Own Background Agent at LayerX
layerx
PRO
10
5.3k
Flow は今どうなっているか
mizdra
PRO
0
150
Android CLI
fornewid
0
220
AIが無かった頃の素敵な出会いの話
codmoninc
1
420
170k Jobs a Day on GKE: Scaling Mercari's CI Platform - and What's Next for AI-Native Development
junyaokabe
0
110
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
220
源内ハンズオン概要編
hideg
0
170
Featured
See All Featured
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
370
Test your architecture with Archunit
thirion
1
2.3k
Faster Mobile Websites
deanohume
310
32k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Product Roadmaps are Hard
iamctodd
55
12k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.9k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
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