Continuing my exploration of
Concurrent
- I tried in my program replacing
Concurrent.parMapN
with a
ParApplicative
instance (obtained by
Concurrent.parApplicative(ctx)
). Then, I replaced
parMapN
with
mapN
and checked which threads effects passed to
mapN
were executed in. To my surprise, they were executed in the caller's thread:
C.parApplicative(dispatchers().io()).run {
mapN(getAthleteActivities(), getAthlete()) { (apiActivities, apiAthlete) -> /* transform */ }
}
I checked quickly the implementation; to have a concurrent execution, I have to use
map2
extension function:
C.parApplicative(dispatchers().io()).run {
getAthleteActivities().map2(getAthlete()) { (apiActivities, apiAthlete) -> /* transform */ }
}
Is this a conscious design decision? Should
mapN
be delegated to
parMapN
?