July 2018
Intermediate to advanced
266 pages
7h 11m
English
One specific goal of the Kotlin team was to make as few language changes as possible in order to support concurrency. Instead, the impact of supporting coroutines and concurrency was to be taken by the compiler, the standard library, and the coroutines library. So the only relevant change from a language perspective is the addition of the suspend modifier.
This modifier indicates to the compiler that the code in the given scope—function or lambda—will work using continuations. So whenever a suspending computation is compiled, its bytecode will be a big continuation. For example, let's consider this suspending function:
suspend fun getUserSummary(id: Int): UserSummary { logger.log("fetching summary of $id") val profile ...
Read now
Unlock full access