> If you're polling on a single file/socket descriptor, > both APIs do about the same processing on the first poll > (mostly just copying from the apr_pollfd_t to the OS's > pollfd struct). If you expect to have to call poll on > that same descriptor repeatedly, the apr_pollset API > is more efficient than the apr_poll API, because the > pollset API doesn't have to repeat this setup work on > subsequent requests. On the other hand, to take > advantage of this property of the apr_pollset API, > you need to be able to keep track of the pollset > object between calls. In situations where it's > prohibitively complex for the app to maintain a pollset > object, the apr_poll API is simpler to use. > > For larger numbers of descriptors, the apr_pollset > API scales better than apr_poll, as the pollset code > doesn't need to do an O(n) copy on each poll call.
I should point out for completeness that apr_poll is O(2n), and apr_pollset is O(n). Both functions do a traversal through the list after calling poll to set the return events correctly. Ryan
