According to this blog post there's a potential performance issue with for comprehensions. For example:
for {
a <- remoteCallA()
b <- remoteCallB()
} yield {
(a, b)
}
has remoteCallB
blocked until remoteCallA
is completed. The blog post suggests that we do this instead:
futureA <- remoteCallA()
futureB <- remoteCallB()
for {
a <- futureA
b <- futureB
} yield {
(a, b)
}
which will ensure that the two remote calls can start at the same time.
My question: is the above (and therefore the blog writer) correct?
I've not seen people using this pattern, which has got me wondering whether there are alternative patterns that are generally used instead.
With thanks