https://kotlinlang.org logo
#coroutines
Title
# coroutines
l

liminal

12/31/2019, 3:06 PM
Hi all, trying to wrap my head around this. The
lookupImagesWithAsync()
should be faster since two images are downloaded in parallel, correct?
imageRepository.downloadImage(imagePath)
is a
suspend
function that does its work in
withContext(<http://Dispatchers.IO|Dispatchers.IO>)
d

Dominaezzz

12/31/2019, 3:12 PM
Yes, it should be faster.
l

liminal

12/31/2019, 3:15 PM
Thanks, Dominic. so in
lookupImages()
imageRepository.downloadImage("img-url-2")
does not start the download process until
imageRepository.downloadImage("img-url-1")
returns
image1
?
d

Dominaezzz

12/31/2019, 3:16 PM
Exactly
They are synchronous.
l

liminal

12/31/2019, 3:17 PM
ok either my way of measuring is not correct or i am just running into caching issues which make the results not what i would expect
d

Dominaezzz

12/31/2019, 3:20 PM
Your measurement looks fine.
l

liminal

12/31/2019, 3:20 PM
cool thanks for confirming, @Dominaezzz