Kotlin -- The suspend modifier under the hood

Click for: original source

Kotlin coroutines introduced the suspend modifier in our daily life as Android developers. By Manuel Vivo.

In this tutorial author will look under the hood and answer the question: How is the compiler transforming the code to be able to suspend and resume the execution of coroutines? How is the compiler transforming the code to be able to suspend and resume the execution of coroutines?

The article content is split into sections:

  • Coroutines 101
  • Suspend under the hood
  • Continuation interface
  • Using different Dispatchers
  • The generated State machine

The Kotlin compiler will create a state machine for every suspend function that manages the coroutine’s execution for us! Very useful for anybody interested in Kotlin!

[Read More]

Tags java kotlin programming app-development