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

marcelo

11/02/2018, 10:11 PM
maybe using
async
and
await
?
j

Jonathan Walsh

11/02/2018, 10:24 PM
I think
async
is what you need along with
awaitAll
m

marcelo

11/02/2018, 10:25 PM
thank you Jonathan!
j

Jonathan Walsh

11/02/2018, 10:25 PM
Copy code
return pkg.templates.map { renderTemplatePath ->{ 
    async {
       timer.time{
         //...
      }
    }
   }.awaitAll().toSet()
m

marcelo

11/02/2018, 10:25 PM
checking it out...
j

Jonathan Walsh

11/02/2018, 10:25 PM
let me know if that works, I’m still learning too
f

Felix

11/02/2018, 10:34 PM
I believe
awaitAll
is also a
suspend
function, so you can only call if from another
suspend
function or lambda.
Why do you want to make
createRenders
async? What blocking operations are you doing inside it?
m

marcelo

11/02/2018, 10:38 PM
yeah, I'm getting the dreaded "...should be called from another ..." right what @Felix said
I have a
timer
function which does the async inside
gtg - dinner time
n

nwh

11/03/2018, 12:20 AM
Why isn't
createRenders
a suspending function?
m

marcelo

11/03/2018, 2:20 AM
createRenders
is a legacy app that I inherited.