• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 import kotlinx.coroutines.*
2 import kotlinx.coroutines.debug.*
3 
<lambda>null4 suspend fun computeValue(): String = coroutineScope {
5     val one = async { computeOne() }
6     val two = async { computeTwo() }
7     combineResults(one, two)
8 }
9 
combineResultsnull10 suspend fun combineResults(one: Deferred<String>, two: Deferred<String>): String =
11     one.await() + two.await()
12 
13 suspend fun computeOne(): String {
14     delay(5000)
15     return "4"
16 }
17 
computeTwonull18 suspend fun computeTwo(): String {
19     delay(5000)
20     return "2"
21 }
22 
<lambda>null23 fun main() = runBlocking {
24     DebugProbes.install()
25     val deferred = async { computeValue() }
26     // Delay for some time
27     delay(1000)
28     // Dump running coroutines
29     DebugProbes.dumpCoroutines()
30     println("\nDumping only deferred")
31     DebugProbes.printJob(deferred)
32 }