class Async::Barrier
def wait
Wait for all tasks.
def wait # TODO: This would be better with linked list. while @tasks.any? task = @tasks.first begin task.wait ensure # We don't know for sure that the exception was due to the task completion. unless task.running? # Remove the task from the waiting list if it's finished: @tasks.shift if @tasks.first == task end end end end