In Android NDK, what is the difference between ALooper_pollOnce()
and ALooper_pollAll()
?
These simple specify how many (maximum) callbacks to process from Looper's event queue. As names suggest, pollAll()
executes all callbacks from the event queue until the data event, error or timeout is encountered. On the other hand, pollOnce()
returns ALOOPER_POLL_CALLBACK as soon as first callback is executed.
Basically, their relationship can be expressed in the following pseudocode:
int ALooper_pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData) {
int result;
do {
result = ALooper_pollOnce(timeoutMillis, outFd, outEvents, outData);
} while (result == ALOOPER_POLL_CALLBACK);
return result;
}