Function AsyncOperationRequest.waitForCompletion

Waits until the request has completed - successfully or otherwise - and returns the response object. It will run an ad-hoc event loop that may call other callbacks while waiting.

abstract AsyncOperationResponse waitForCompletion();

The response object may be embedded in the request object - do not reuse the request until you are finished with the response and do not keep the response around longer than you keep the request.

Note to implementers: all subclasses should override this and return their specific response object. You can use the top-level waitForFirstToCompleteByIndex function with a single-element static array to help with the implementation.