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.exampleCompose05
7 
8 import kotlinx.coroutines.*
9 import kotlin.system.*
10 
<lambda>null11 fun main() = runBlocking<Unit> {
12     val time = measureTimeMillis {
13         println("The answer is ${concurrentSum()}")
14     }
15     println("Completed in $time ms")
16 }
17 
<lambda>null18 suspend fun concurrentSum(): Int = coroutineScope {
19     val one = async { doSomethingUsefulOne() }
20     val two = async { doSomethingUsefulTwo() }
21     one.await() + two.await()
22 }
23 
doSomethingUsefulOnenull24 suspend fun doSomethingUsefulOne(): Int {
25     delay(1000L) // pretend we are doing something useful here
26     return 13
27 }
28 
doSomethingUsefulTwonull29 suspend fun doSomethingUsefulTwo(): Int {
30     delay(1000L) // pretend we are doing something useful here, too
31     return 29
32 }
33