Continuing my exploration of `Concurrent` - I trie...
# arrow
m
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:
Copy code
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:
Copy code
C.parApplicative(dispatchers().io()).run {
    getAthleteActivities().map2(getAthlete()) { (apiActivities, apiAthlete) -> /* transform */ }
}
Is this a conscious design decision? Should
mapN
be delegated to
parMapN
?
s
That’s strange since it does delegated to
parMapN
.
mapN
is derived from
product
, which delegates to
parTupledN
.
m
map2
delegates to
parMapN
(source)
mapN
, defined in
Apply
typeclass, is not overridden by
ParApplicative
.
Should I file an issue for that?
s
Thanks for bringing this up!
m