Combines set of Futures.

    :param futures: (Futures), Futures to be combined.
    :return: Result of the combination.

def combine_futures(*futures):
    """
    Combines set of Futures.

    :param futures: (Futures), Futures to be combined.
    :return: Result of the combination.
    """
    expected = len(futures)
    results = []
    completed = AtomicInteger()
    combined = Future()

    def done(f):
        if not combined.done():
            if f.is_success():  # TODO: ensure ordering of results as original list
                results.append(f.result())
                if completed.get_and_increment() + 1 == expected:
                    combined.set_result(results)
            else:
                combined.set_exception(f.exception(), f.traceback())

    for future in futures:
        future.add_done_callback(done)

    return combined