It returns the request so you can identify it more easily. request.waitForCompletion() is guaranteed to return the response without any actual wait, since it is already complete when this function returns.

Please note that "completion" is not necessary successful completion; a request being cancelled or encountering an error also counts as it being completed.

The waitForFirstToCompleteByIndex version instead returns the index of the array entry that completed first.

It is your responsibility to remove the completed request from the array before calling the function again, since any request already completed will always be immediately returned.

You might prefer using asTheyComplete, which will give each request as it completes and loop over until all of them are complete.


Return Value

Type: size_t

null or requests.length if none completed before returning.