blob: 84f14a113822261fa8aa796845e7d7b07c5ac2e3 [file] [log] [blame]
Roman Elizarovf16fd272017-02-07 11:26:00 +03001/*
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03002 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarovf16fd272017-02-07 11:26:00 +03003 */
4
Roman Elizarovb3d55a52017-02-03 12:47:21 +03005// This file was automatically generated from coroutines-guide.md by Knit tool. Do not edit.
Roman Elizarova9687a32018-06-29 17:28:38 +03006package kotlinx.coroutines.experimental.guide.compose03
Roman Elizarov1293ccd2017-02-01 18:49:54 +03007
Roman Elizarov96695782017-10-01 10:48:15 -07008import kotlinx.coroutines.experimental.*
Roman Elizarov9fe5f462018-02-21 19:05:52 +03009import kotlin.system.*
Roman Elizarov1293ccd2017-02-01 18:49:54 +030010
11suspend fun doSomethingUsefulOne(): Int {
12 delay(1000L) // pretend we are doing something useful here
13 return 13
14}
15
16suspend fun doSomethingUsefulTwo(): Int {
17 delay(1000L) // pretend we are doing something useful here, too
18 return 29
19}
20
21fun main(args: Array<String>) = runBlocking<Unit> {
22 val time = measureTimeMillis {
Roman Elizarov66f018c2017-09-29 21:39:03 +030023 val one = async(start = CoroutineStart.LAZY) { doSomethingUsefulOne() }
24 val two = async(start = CoroutineStart.LAZY) { doSomethingUsefulTwo() }
Roman Elizarov1293ccd2017-02-01 18:49:54 +030025 println("The answer is ${one.await() + two.await()}")
26 }
27 println("Completed in $time ms")
28}