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

More Related Content

What's hot (20)

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

Similar to Asynchronous Programming in Kotlin with Coroutines (20)

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

Recently uploaded (20)

PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Tally software_Introduction_Presentation
AditiBansal54083
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Ad

Asynchronous Programming in Kotlin with Coroutines