Olli Helenius
07/14/2021, 7:19 AMval x = (async { foo() }).await()
ever different from just val x = foo()
?ephemient
07/14/2021, 7:36 AMvar i = 0
launch { i++ }
val x = i
var j = 0
launch { j++ }
val y = async { j }.await()
x == 0 && y == 1
(not guaranteed, but likely in a single threaded dispatcher)Olli Helenius
07/14/2021, 7:40 AMasync
call is a suspension point?uli
07/14/2021, 7:41 AMawait
isOlli Helenius
07/14/2021, 7:41 AMfoo()
in my example is a suspend fun
does it make any difference in that case?uli
07/14/2021, 7:43 AMOlli Helenius
07/14/2021, 7:45 AMasync
make any difference? the call to foo()
is also a suspension point right?uli
07/14/2021, 7:47 AMfoo
will not suspend:
suspend fun foo(): Int { return 1 }
wasyl
07/14/2021, 7:48 AMOlli Helenius
07/14/2021, 7:50 AM