fiber\await_any()
Return the result of the first awaitable to fulfil.
function fiber\await_any(array $awaitables, float $timeout = PHP_FLOAT_MAX): mixed
Behaviour
Rejections are ignored while any awaitable is still pending; if all reject, the exception of the first to reject is thrown. An empty array throws ValueError. On timeout a TimeoutException is thrown. The other awaitables keep running.
Example
<?php
require __DIR__ . '/vendor/autoload.php';
use function fiber\{run, go, await_any, sleep};
run(function () {
echo await_any([go(function () { sleep(0.3); return 'slow'; }), go(function () { sleep(0.05); return 'fast'; })]), "\n";
});