1 // This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. 2 package kotlinx.coroutines.guide.exampleCompose05 3 4 import kotlinx.coroutines.* 5 import kotlin.system.* 6 <lambda>null7fun main() = runBlocking<Unit> { 8 val time = measureTimeMillis { 9 println("The answer is ${concurrentSum()}") 10 } 11 println("Completed in $time ms") 12 } 13 <lambda>null14suspend fun concurrentSum(): Int = coroutineScope { 15 val one = async { doSomethingUsefulOne() } 16 val two = async { doSomethingUsefulTwo() } 17 one.await() + two.await() 18 } 19 doSomethingUsefulOnenull20suspend fun doSomethingUsefulOne(): Int { 21 delay(1000L) // pretend we are doing something useful here 22 return 13 23 } 24 doSomethingUsefulTwonull25suspend fun doSomethingUsefulTwo(): Int { 26 delay(1000L) // pretend we are doing something useful here, too 27 return 29 28 } 29