Deferred Await All

Here's an example for usage about it.

CoroutineGen::runBlocking(
    function () : Generator {
        $numberA = new Deferred(function () : Generator {
            yield from CoroutineGen::delay(2000);
            return 5;
        });

        $numberB = new Deferred(function () : Generator {
            yield from CoroutineGen::delay(2000);
            return 10;
        });

        [$a, $b] = yield from Deferred::awaitAll($numberA, $numberB);

        var_dump($a + $b);
    }
);

Last updated