functions.php
Table of Contents
Functions
- awaitFirst() : T
- Unwraps the first completed future.
- awaitAny() : Tv
- Awaits the first successfully completed future, ignoring errors.
- awaitAnyN() : array<string|int, mixed>
- Awaits the first N successfully completed futures, ignoring errors.
- awaitAll() : array<string|int, mixed>
- Awaits all futures to complete or error.
- await() : array<string|int, mixed>
- Awaits all futures to complete or aborts if any errors.
Functions
awaitFirst()
Unwraps the first completed future.
awaitFirst(iterable<string|int, Future<string|int, T>> $futures[, Cancellation|null $cancellation = null ]) : T
If you want the first future completed without an error, use awaitAny() instead.
Parameters
- $futures : iterable<string|int, Future<string|int, T>>
- $cancellation : Cancellation|null = null
-
Optional cancellation.
Tags
Return values
TawaitAny()
Awaits the first successfully completed future, ignoring errors.
awaitAny(iterable<Tk, Future<string|int, Tv>> $futures[, Cancellation|null $cancellation = null ]) : Tv
If you want the first future completed, successful or not, use awaitFirst() instead.
Parameters
- $futures : iterable<Tk, Future<string|int, Tv>>
- $cancellation : Cancellation|null = null
-
Optional cancellation.
Tags
Return values
TvawaitAnyN()
Awaits the first N successfully completed futures, ignoring errors.
awaitAnyN(positive-int $count, iterable<Tk, Future<string|int, Tv>> $futures[, Cancellation|null $cancellation = null ]) : array<string|int, mixed>
Parameters
- $count : positive-int
- $futures : iterable<Tk, Future<string|int, Tv>>
- $cancellation : Cancellation|null = null
-
Optional cancellation.
Tags
Return values
array<string|int, mixed>awaitAll()
Awaits all futures to complete or error.
awaitAll(iterable<Tk, Future<string|int, Tv>> $futures[, Cancellation|null $cancellation = null ]) : array<string|int, mixed>
This awaits all futures without aborting on first error (unlike await()).
Parameters
- $futures : iterable<Tk, Future<string|int, Tv>>
- $cancellation : Cancellation|null = null
-
Optional cancellation.
Tags
Return values
array<string|int, mixed>await()
Awaits all futures to complete or aborts if any errors.
await(iterable<Tk, Future<string|int, Tv>> $futures[, Cancellation|null $cancellation = null ]) : array<string|int, mixed>
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.
Parameters
- $futures : iterable<Tk, Future<string|int, Tv>>
- $cancellation : Cancellation|null = null
-
Optional cancellation.