Created
June 16, 2017 18:25
-
-
Save msgile/9d5b30970e2f0b8073d04efed6fb63db to your computer and use it in GitHub Desktop.
Kotlin example of using coroutines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun computer(): Int = runBlock { | |
val partA = async(CommonPool) { computeA() } | |
val partB = async(CommonPool) { computeB() } | |
partA.await() + partB.await() //last command emits results | |
} | |
val total = computer() // = 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment