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

Reisishot

06/11/2019, 3:54 PM
I just found out that this is the cause of the problem: (this being a Map)
Copy code
keys.forEach { priority ->
            get(priority)?.forEachLimitedParallel(callable)
                ?: throw IllegalStateException("No list found for priority $priority")
        }
d

Dico

06/11/2019, 4:02 PM
Replace
runBlocking
with
coroutineScope
and make your for each function
suspend
Then, invoke the for each function from the scope you want it to use (and remove parameter from
launch
)
Alternatively, create worker coroutines that take items from a channel
r

Reisishot

06/11/2019, 4:08 PM
@Dico I added the parameter to launch in orderr to limit my parallelity
Do you have any idea on how to achive this?
With unlimited paralelism I will run out of memory
Removing the parameter from launch worked BTW...
@Dico Thank you, works now 😄
d

Dico

06/11/2019, 4:48 PM
You should have the dispatcher you made in the coroutine context when you call the function.
4 Views