SlideShare a Scribd company logo
1 ••
Rhein-Neckar Dev Meetup #1
2 ••
Asynchronous progamming in Kotlin with Coroutines
🍕 🍕 🍕
Tensorflowing like a pro - without a clue
3 ••
Coroutines
Asynchronous programming in Kotlin
4 ••
How programming works
Intro
Do something (create a resource)
↓
Wait (for completion)
↓
Do something (send it to backend)
↓
Wait (for the response)
↓
Do something (process response or try again)
↓
…
5 ••
Dealing with long running tasks
Asynchronicity
- Direct style
- max 16 ms
- Blocking the main Thread
- Callback
- Error Handling
- Callback Hell
- Futures (RxJava, Promises, …)
- Idea: we wrap the result
- Pro: nice code, errors, good looking
- cons: complex
- Coroutines
- Direct style
6 ••
What is a Coroutine?
- It’s an instance of a suspendable computation
- General concept was already created in 1958
- Similar to a very lightweight Thread – cheap in creation
- Looks like regular blocking code
- Coroutines give us a way to write code that feels imperative, even if it is asynchronous.
7 •• ••
Suspend functions
- A function ‘super powers’
- It’s a function which can suspend and return a value later on
8 •• ••
Suspend functions II
- Suspension points
- Many things work out-of-the box
- Loops
- Exceptions
- Higher-Order-Functions
- …
9 ••
suspension functions are designed to
imitate sequential behavior by default
10 ••
Setup
11 ••
Demo I
- Sample + Performance
12 ••
https://www.slideshare.net/elizarov/deep-dive-into-coroutines-on-jvm-kotlinconf-2017
Coroutines in detail
13 ••
14 ••
15 ••
16 ••
17 ••
18 ••
19 ••
20 ••
Reuse closure / state object
State Machine vs Callbacks
Easier loop
21 ••
Suspending functions cannot be invoked from
regular functions
• launch (fire and forget)
• async (and await)
• Returns a Deferred
• runBlocking
• Not keywords but functions!
Coroutine Builder
22 ••
Demo II
– Coroutine Builders
23 ••
Coroutine Context
- *without*
- UI
- CommonPool
- Unconfined
24 ••
Demo III
– Channels and Actors
- Comparison RX
25 ••
Questions?
Pizza?
26 ••
Links & References
- Coroutines guide Informal
- https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md
- Coroutine guide reactive
- https://github.com/Kotlin/kotlinx.coroutines/blob/master/reactive/coroutines-guide-reactive.md
- Deep dive into Coroutines on JVM, KotlinConf 2017 – Roman Elizarov
https://www.slideshare.net/elizarov/deep-dive-into-coroutines-on-jvm-kotlinconf-2017
- Images from https://www.pexels.com
Ad

Recommended

EhTrace -- RoP Hooks
EhTrace -- RoP Hooks
Shane Macaulay
 
JDD 2016 - Andrej Mihály - How To Bake Reactive Behavior Into Your Java Ee Ap...
JDD 2016 - Andrej Mihály - How To Bake Reactive Behavior Into Your Java Ee Ap...
PROIDEA
 
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
Clojure Conj 2014 - Paradigms of core.async - Julian Gamble
Julian Gamble
 
Rabbits, indians and... Symfony meets queueing brokers
Rabbits, indians and... Symfony meets queueing brokers
Gaetano Giunta
 
Making Symfony Services async with RabbitMq (and more Symfony)
Making Symfony Services async with RabbitMq (and more Symfony)
Gaetano Giunta
 
CBDW2014 - Down the RabbitMQ hole with ColdFusion
CBDW2014 - Down the RabbitMQ hole with ColdFusion
Ortus Solutions, Corp
 
VMware studio practice in TIM
VMware studio practice in TIM
Yi-Huan Chan
 
Realtime web2012
Realtime web2012
Timothy Fitz
 
Zero mq logs
Zero mq logs
Tomas Doran
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Adler Hsieh
 
Sonata Block Bundle - sfPot March 2014
Sonata Block Bundle - sfPot March 2014
th0masr
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
Enterprise messaging
Enterprise messaging
ColdFusionConference
 
A look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architecture
Aimee Maree Forsstrom
 
They why behind php frameworks
They why behind php frameworks
Kirk Madera
 
Coroutines in Kotlin
Coroutines in Kotlin
Jemo Mgebrishvili
 
MongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUG
MongoDB
 
Capistrano demo
Capistrano demo
Edward Meehan
 
Riak at Posterous
Riak at Posterous
capotej
 
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Ortus Solutions, Corp
 
Cooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
bol.com Dutch Container Day presentation
bol.com Dutch Container Day presentation
Maarten Dirkse
 
Hybrid concurrency patterns
Hybrid concurrency patterns
Kyle Drake
 
CI/CD at bol.com
CI/CD at bol.com
Maarten Dirkse
 
OSBConf 2015 | Vm backup beyond bacula by christian theune
OSBConf 2015 | Vm backup beyond bacula by christian theune
NETWAYS
 
Vmth project
Vmth project
Ricardo Sanchez
 
How to stuff a 900 pound gorilla into a smartphone
How to stuff a 900 pound gorilla into a smartphone
Joel Maher
 
Ratpack for Real
Ratpack for Real
TomAkehurst
 
Kotlin Coroutines and Android sitting in a tree
Kotlin Coroutines and Android sitting in a tree
Kai Koenig
 
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
DroidConTLV
 

More Related Content

What's hot (20)

Zero mq logs
Zero mq logs
Tomas Doran
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Adler Hsieh
 
Sonata Block Bundle - sfPot March 2014
Sonata Block Bundle - sfPot March 2014
th0masr
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
Enterprise messaging
Enterprise messaging
ColdFusionConference
 
A look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architecture
Aimee Maree Forsstrom
 
They why behind php frameworks
They why behind php frameworks
Kirk Madera
 
Coroutines in Kotlin
Coroutines in Kotlin
Jemo Mgebrishvili
 
MongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUG
MongoDB
 
Capistrano demo
Capistrano demo
Edward Meehan
 
Riak at Posterous
Riak at Posterous
capotej
 
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Ortus Solutions, Corp
 
Cooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
bol.com Dutch Container Day presentation
bol.com Dutch Container Day presentation
Maarten Dirkse
 
Hybrid concurrency patterns
Hybrid concurrency patterns
Kyle Drake
 
CI/CD at bol.com
CI/CD at bol.com
Maarten Dirkse
 
OSBConf 2015 | Vm backup beyond bacula by christian theune
OSBConf 2015 | Vm backup beyond bacula by christian theune
NETWAYS
 
Vmth project
Vmth project
Ricardo Sanchez
 
How to stuff a 900 pound gorilla into a smartphone
How to stuff a 900 pound gorilla into a smartphone
Joel Maher
 
Ratpack for Real
Ratpack for Real
TomAkehurst
 
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Automating Your Daily Tasks with Scripting - RubyConf 2015 Taiwan
Adler Hsieh
 
Sonata Block Bundle - sfPot March 2014
Sonata Block Bundle - sfPot March 2014
th0masr
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Ortus Solutions, Corp
 
A look at FastCgi & Mod_PHP architecture
A look at FastCgi & Mod_PHP architecture
Aimee Maree Forsstrom
 
They why behind php frameworks
They why behind php frameworks
Kirk Madera
 
MongoDB backup service overview Boston MUG
MongoDB backup service overview Boston MUG
MongoDB
 
Riak at Posterous
Riak at Posterous
capotej
 
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Ortus Solutions, Corp
 
Cooking a rabbit pie
Cooking a rabbit pie
Tomas Doran
 
bol.com Dutch Container Day presentation
bol.com Dutch Container Day presentation
Maarten Dirkse
 
Hybrid concurrency patterns
Hybrid concurrency patterns
Kyle Drake
 
OSBConf 2015 | Vm backup beyond bacula by christian theune
OSBConf 2015 | Vm backup beyond bacula by christian theune
NETWAYS
 
How to stuff a 900 pound gorilla into a smartphone
How to stuff a 900 pound gorilla into a smartphone
Joel Maher
 
Ratpack for Real
Ratpack for Real
TomAkehurst
 

Similar to Asynchronous Programming in Kotlin with Coroutines (20)

Kotlin Coroutines and Android sitting in a tree
Kotlin Coroutines and Android sitting in a tree
Kai Koenig
 
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
DroidConTLV
 
Coroutines in Kotlin
Coroutines in Kotlin
Alexey Soshin
 
Android kotlin coroutines
Android kotlin coroutines
Bipin Vayalu
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring framework
Sunghyouk Bae
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutines
Roman Elizarov
 
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
Ahmed Nabil
 
Current State of Coroutines
Current State of Coroutines
Guido Pio Mariotti
 
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kai Koenig
 
Should it be routine to use coroutines?
Should it be routine to use coroutines?
Ion Stefan Brosteanu
 
Coroutines in Kotlin. In-depth review
Coroutines in Kotlin. In-depth review
Dmytro Zaitsev
 
Coroutines in Kotlin. UA Mobile 2017.
Coroutines in Kotlin. UA Mobile 2017.
UA Mobile
 
Coroutines in Kotlin
Coroutines in Kotlin
Dmytro Zaitsev
 
CommitConf 2018 - Going Async With Kotlin
CommitConf 2018 - Going Async With Kotlin
Jose Mº Muñoz
 
Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?
Artur Latoszewski
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Lauren Yew
 
2019-01-29 - Demystifying Kotlin Coroutines
2019-01-29 - Demystifying Kotlin Coroutines
Eamonn Boyle
 
Quick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android Dev
Shuhei Shogen
 
Introduction to kotlin coroutines
Introduction to kotlin coroutines
NAVER Engineering
 
Kotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutines
Franco Lombardo
 
Kotlin Coroutines and Android sitting in a tree
Kotlin Coroutines and Android sitting in a tree
Kai Koenig
 
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
Lean way write asynchronous code with Kotlin’s coroutines - Ronen Sabag, Gett
DroidConTLV
 
Coroutines in Kotlin
Coroutines in Kotlin
Alexey Soshin
 
Android kotlin coroutines
Android kotlin coroutines
Bipin Vayalu
 
Kotlin coroutines and spring framework
Kotlin coroutines and spring framework
Sunghyouk Bae
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutines
Roman Elizarov
 
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
DroidConEgypt-21-10-2022-Coroutines-AhmedNabil.pdf
Ahmed Nabil
 
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kotlin Coroutines and Android sitting in a tree - 2018 version
Kai Koenig
 
Should it be routine to use coroutines?
Should it be routine to use coroutines?
Ion Stefan Brosteanu
 
Coroutines in Kotlin. In-depth review
Coroutines in Kotlin. In-depth review
Dmytro Zaitsev
 
Coroutines in Kotlin. UA Mobile 2017.
Coroutines in Kotlin. UA Mobile 2017.
UA Mobile
 
CommitConf 2018 - Going Async With Kotlin
CommitConf 2018 - Going Async With Kotlin
Jose Mº Muñoz
 
Kotlin coroutine - the next step for RxJava developer?
Kotlin coroutine - the next step for RxJava developer?
Artur Latoszewski
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Lauren Yew
 
2019-01-29 - Demystifying Kotlin Coroutines
2019-01-29 - Demystifying Kotlin Coroutines
Eamonn Boyle
 
Quick Introduction to Kotlin Coroutine for Android Dev
Quick Introduction to Kotlin Coroutine for Android Dev
Shuhei Shogen
 
Introduction to kotlin coroutines
Introduction to kotlin coroutines
NAVER Engineering
 
Kotlin from-scratch 3 - coroutines
Kotlin from-scratch 3 - coroutines
Franco Lombardo
 
Ad

Recently uploaded (20)

IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Azure AI Foundry: The AI app and agent factory
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
IObit Driver Booster Pro 12 Crack Latest Version Download
IObit Driver Booster Pro 12 Crack Latest Version Download
pcprocore
 
Canva Pro Crack Free Download 2025-FREE LATEST
Canva Pro Crack Free Download 2025-FREE LATEST
grete1122g
 
Sysinfo OST to PST Converter Infographic
Sysinfo OST to PST Converter Infographic
SysInfo Tools
 
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
Application Modernization with Choreo - The AI-Native Internal Developer Plat...
WSO2
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
Zoho Creator Solution for EI by Elsner Technologies.docx
Zoho Creator Solution for EI by Elsner Technologies.docx
Elsner Technologies Pvt. Ltd.
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Best MLM Compensation Plans for Network Marketing Success in 2025
Best MLM Compensation Plans for Network Marketing Success in 2025
LETSCMS Pvt. Ltd.
 
Microsoft-365-Administrator-s-Guide1.pdf
Microsoft-365-Administrator-s-Guide1.pdf
mazharatknl
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Capability Deck 2025: Accelerating Innovation Through Intelligent Soft...
Emvigo Technologies
 
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
Foundations of Marketo Engage - Programs, Campaigns & Beyond - June 2025
BradBedford3
 
Digital Transformation: Automating the Placement of Medical Interns
Digital Transformation: Automating the Placement of Medical Interns
Safe Software
 
Azure AI Foundry: The AI app and agent factory
Azure AI Foundry: The AI app and agent factory
Maxim Salnikov
 
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
OpenChain Webinar - AboutCode - Practical Compliance in One Stack – Licensing...
Shane Coughlan
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
Ad

Asynchronous Programming in Kotlin with Coroutines