1 /* 2 * Copyright 2016-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5 // This file was automatically generated from composing-suspending-functions.md by Knit tool. Do not edit. 6 package kotlinx.coroutines.guide.exampleCompose03 7 8 import kotlinx.coroutines.* 9 import kotlin.system.* 10 <lambda>null11fun main() = runBlocking<Unit> { 12 val time = measureTimeMillis { 13 val one = async(start = CoroutineStart.LAZY) { doSomethingUsefulOne() } 14 val two = async(start = CoroutineStart.LAZY) { doSomethingUsefulTwo() } 15 // some computation 16 one.start() // start the first one 17 two.start() // start the second one 18 println("The answer is ${one.await() + two.await()}") 19 } 20 println("Completed in $time ms") 21 } 22 doSomethingUsefulOnenull23suspend fun doSomethingUsefulOne(): Int { 24 delay(1000L) // pretend we are doing something useful here 25 return 13 26 } 27 doSomethingUsefulTwonull28suspend fun doSomethingUsefulTwo(): Int { 29 delay(1000L) // pretend we are doing something useful here, too 30 return 29 31 } 32