apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Bloom" <...@covalent.net>
Subject RE: [PATCH] poll.c pollacc.c ab.c
Date Sun, 04 Aug 2002 21:34:45 GMT
> 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.


View raw message