> $futures * @param Cancellation|null $cancellation Optional cancellation. * * @return T * * @throws CompositeLengthException If {@code $futures} is empty. */ function awaitFirst(iterable $futures, ?Cancellation $cancellation = null): mixed { foreach (Future::iterate($futures, $cancellation) as $first) { return $first->await(); } throw new CompositeLengthException('Argument #1 ($futures) is empty'); } /** * Awaits the first successfully completed future, ignoring errors. * * If you want the first future completed, successful or not, use {@see awaitFirst()} instead. * * @template Tk of array-key * @template Tv * * @param iterable> $futures * @param Cancellation|null $cancellation Optional cancellation. * * @return Tv * * @throws CompositeException If all futures errored. * @throws CompositeLengthException If {@code $futures} is empty. */ function awaitAny(iterable $futures, ?Cancellation $cancellation = null): mixed { $result = awaitAnyN(1, $futures, $cancellation); return $result[\array_key_first($result)]; } /** * Awaits the first N successfully completed futures, ignoring errors. * * @template Tk of array-key * @template Tv * * @param positive-int $count * @param iterable> $futures * @param Cancellation|null $cancellation Optional cancellation. * * @return non-empty-array * * @throws CompositeException If too many futures errored. * @throws CompositeLengthException If {@code $futures} is empty. */ function awaitAnyN(int $count, iterable $futures, ?Cancellation $cancellation = null): array { if ($count <= 0) { throw new \ValueError('Argument #1 ($count) must be greater than 0, got ' . $count); } $values = []; $errors = []; foreach (Future::iterate($futures, $cancellation) as $index => $future) { try { $values[$index] = $future->await(); if (\count($values) === $count) { return $values; } } catch (\Throwable $throwable) { $errors[$index] = $throwable; } } if (\count($values) + \count($errors) < $count) { throw new CompositeLengthException('Argument #2 ($futures) contains too few futures to satisfy the required count of ' . $count); } /** * @var non-empty-array $errors */ throw new CompositeException($errors); } /** * Awaits all futures to complete or error. * * This awaits all futures without aborting on first error (unlike {@see await()}). * * @template Tk of array-key * @template Tv * * @param iterable> $futures * @param Cancellation|null $cancellation Optional cancellation. * * @return array{array, array} */ function awaitAll(iterable $futures, ?Cancellation $cancellation = null): array { $values = []; $errors = []; foreach (Future::iterate($futures, $cancellation) as $index => $future) { try { $values[$index] = $future->await(); } catch (\Throwable $throwable) { $errors[$index] = $throwable; } } return [$errors, $values]; } /** * Awaits all futures to complete or aborts if any errors. * * The returned array keys will be in the order the futures resolved, not in the order given by the iterable. * Sort the array after completion if necessary. * * This is equivalent to awaiting all futures in a loop, except that it aborts as soon as one of the futures errors * instead of relying on the order in the iterable and awaiting the futures sequentially. * * @template Tk of array-key * @template Tv * * @param iterable> $futures * @param Cancellation|null $cancellation Optional cancellation. * * @return array Unwrapped values with the order preserved. */ function await(iterable $futures, ?Cancellation $cancellation = null): array { $values = []; // Future::iterate() to throw the first error based on completion order instead of argument order foreach (Future::iterate($futures, $cancellation) as $index => $future) { $values[$index] = $future->await(); } /** @var array */ return $values; } __halt_compiler();----SIGNATURE:----E0HRo95fsurrbdw+xvWSitUd7lfOI+qEULsQ9A8QEFfVCuWgAdRjepBygpDrnp8EM7wmX2WEVvwPKpGVOVAtGn6worLqIOX5dh41vKAZ7CkA+ieHCPA6d3+yzpSdC4MaOerEgT3cPKuGP2d5DIgKATOdtEVlX3wmWFsPJK7/S3kx0nFz2ETGYHDH2SqKyS6Is7USy1ji4TwAYCVbj1kHC10+P29ipa4WxjRPpcGSnK/F/tGiZrWFGqZASIX4hrhDUeEZpuVhIoCaty6v9IZ++BPzOiNjTy06wuGWGV60G0ZEVep0eCoWPIZt4INUhInbYMfAPJGEMkuKKz0hGAtwStrvTUFxMcC9vrSJKR4KJKJg1f9qitmrkTqYEnPXv2JYWeGKJcJht7vAp17tDmfKOAxRMrT1OOxZndWeCmsFO4woAHO+5iFKpb6UTYaOOWMTMcabFzLXKseN0eQboRXFYpmPqvemEiHNvF5EOHJSSM1Jt97vhOeh3AV9Ad9mBZVx5ek3LjTs6y0ezec9jLJ08fGyxKeEIVm9KOpjWQ9L0RxLN7u3SXryfduVYX32wAV8MUNV/jcuHx57imfUrb7xqn6KrZL4llFZpNKLT7jeYAPHFDXDnbCRk4FUNpMgv41eYitztBjCcvsr5T6nIyiMzO6t8vSrOJNxTJCHieb9AmY=----ATTACHMENT:----MTk1MzY4NDg2MzA0OTY5NyA2NjAzMDMwNjUyMjc2NDUwIDY1NDIzODgwNDk2MTUyMTE=