Kotlin

Structured Concurrency in Kotlin

suspend functions

Launching coroutines

Dispatcher

Channels

Using async/await in Kotlin

  • The main crawl method defines high level scope of concurrency and it waits for the completion of child tasks.
  • Kotlin supports cancellation and timeout APIs and the crawl method will fail with timeout error if crawling exceeds the time limit.
  • The crawl method captures error from async response and returns so that client code can perform error handling.
  • The async syntax in Kotlin allows easy composition of asynchronous code.
  • Kotlin allows customized dispatcher for more control on the asynchronous behavior.
  • As Kotlin doesn’t enforce immutability by default, you will need synchronization to protect shared state.
  • Async/Await support is still new in Kotlin and lacks stability and proper documentation.
  • Above design creates a new coroutine for crawling each URL and it can strain expensive network and IO resources so it’s not practical for real-world implementation.

Using coroutines in Kotlin

Swift

Structured Concurrency in Swift

Coroutines

Async/Await

Actor model

Structured Concurrency Comparison

Performance Comparison

Summary

--

--

--

Lifelong learner, technologist and a software builder based in Seattle.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

A look at the Wikipedia API

C++20 concepts: part 2

Installing sublime text on Linux

Convert your Xcode project from iPhone to Universal, and update AppIcon accordingly

Relational NoSQL

Everything about Docker that no one told you!

Reducing Burnout with Support Rotations

AWS INFRASTRUCTURE AS CODE (Terraform)- PRIVATE AND PUBLIC SUBNET

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
shahzad bhatti

shahzad bhatti

Lifelong learner, technologist and a software builder based in Seattle.

More from Medium

Microservices in SIPRD

How to Keep your Social Channels Connected — A Complete Guide to Access Tokens

Objective-C: When to use braces in a For Loop declaration?

The Evolution of iOS: From iOS 1 to iOS 16