I'm trying to figure out a decent way to iterate o...
# coroutines
b
I'm trying to figure out a decent way to iterate over a List of
n
items,
k
items at a time, where I can parallelize each set of
k
. So, if I have 20 items and I'm processing 5 at a time, I want to take the first 5, launch each one in parallel, wait for all of them to back, and then take the next 5, and so on. So it's sort of like a backpressured stream. I was thinking of just iterating over the List and doing
repeat (5)
and then launching each one, but that feels a bit ugly to me. Can anyone recommend something that might be a bit tidier?