LwtUtils.all
commit6244369387838d9387c015a48260fa74bdd864cd
authorGabe Levi <gabe@fb.com>
Fri, 23 Mar 2018 23:26:41 +0000 (23 16:26 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Fri, 23 Mar 2018 23:40:32 +0000 (23 16:40 -0700)
tree59d7f9fa37e3cb7ca5e250ad398cfe279a23464b
parente12c5823e4013caf1ab0d031b180ddc9e6e90c7a
LwtUtils.all

Summary:
Lwt.join is documented as so:

```
val join : unit t list -> unit t
```

> join l waits for all threads in l to terminate. If one of the threads fails, then join l will fails with the same exception as the first one to terminate.

When it says it waits for all threads to terminate it isn't joking. It literally waits for every single thread to either finish or fail.

In Hack, when you await a bunch of awaitables, if any of them throw the error is propagated up.

In JavaScript, when you use `Promise.all`, the resulting `Promise` is rejected as soon as any of the promises are rejected.

I had incorrectly been using `Lwt.join` as if it were `Promise.all`, and this caused a bug in MultiWorkerLwt. Hopefully this should fix it.

I chose to make `LwtUtils.all` NOT cancel sleeping threads when one thread fails. I did this for a few reasons:

1. I couldn't figure out a good way to preserve stack traces
2. `Promise.all` doesn't do it so I figure I don't need to do it either :P

Reviewed By: samwgoldman

Differential Revision: D7356590

fbshipit-source-id: 0ecc5cf44c67b3c006820208d13ed51792d01622
hphp/hack/src/procs/multiWorkerLwt.ml