Provides a simple barrier to wait for the completion of a set of tasks represented by
Barrier.
A Barrier can be used to block and wait for the completion of a given set of promises. A barrier should
only be used once and after a call to await, no further promises should be added. Also await
must only be called once.
The general call pattern looks like that:
Barrier b = Barrier.create();
Always prefer
#await(long,java.util.concurrent.TimeUnit) and specify a sane timeout since something
might always go wrong and a promise might therefore not complete (in time - or not at all) and your program
is locked forever.
This barrier can also be used in a non-blocking way, by calling
#asFuture() after the last call to
#add(Promise). If possible, the non-block approach should always be preferred.