asio review -- number of allowed timers

Hopefully this issue hasn't already been discussed -- I apologize if it has -- I've only been able to skim much of the last few days discussion... Another issue discussed by the 'Phoenix Group' (see my IPV4 email for explanation) is the specification of the number of portable timers allowed by asio. As many folks on this list are aware, the number of actual timers that can be set varies by operating system. This fact makes writing portable code that scales to a large number of timers difficult. From our reading of the asio docs there is no statement of limits on the number of timers. One might infer from this that the interface will portably support as many timers as users wish. While this might seem to contradict with OS based limits, it actually doesn't -- ACE and other libraries work around OS limitations by using internal timer queues that minimize (typically to one) the number of actual timers set in the OS. I've had a brief look at the implementation, but it's not clear to me that asio is doing this in all cases. So the questions are: 1) Is the intent to support an 'unlimited' number of timers portably? 2) If yes, does the implementation do this for all platforms? Jeff

Hi Jeff, --- Jeff Garland <jeff@crystalclearsoftware.com> wrote: <snip>
So the questions are:
1) Is the intent to support an 'unlimited' number of timers portably?
Yes.
2) If yes, does the implementation do this for all platforms?
Yes. First a minor clarification to put things in asio terminology: the question is not just about whether you can have an unlimited number of deadline_timer objects, but also whether you can have an unlimited number of pending asynchronous waits. The implementation of a deadline_timer object is just an expiry time (stored as a boost::posix_time::ptime). Each pending asynchronous wait on a timer is represented by an entry in a heap, sorted by expiry. Only the earliest expiry is fed into the demultiplexer as a timeout, so in that sense there is only one OS timer being used. Cheers, Chris

On Sat, 31 Dec 2005 18:16:21 +1100 (EST), Christopher Kohlhoff wrote
--- Jeff Garland <jeff@crystalclearsoftware.com> wrote: <snip>
So the questions are:
1) Is the intent to support an 'unlimited' number of timers portably?
Yes.
2) If yes, does the implementation do this for all platforms?
Yes.
First a minor clarification to put things in asio terminology: the question is not just about whether you can have an unlimited number of deadline_timer objects, but also whether you can have an unlimited number of pending asynchronous waits.
Yep, it's pending waits I was worried about.
The implementation of a deadline_timer object is just an expiry time (stored as a boost::posix_time::ptime).
Each pending asynchronous wait on a timer is represented by an entry in a heap, sorted by expiry. Only the earliest expiry is fed into the demultiplexer as a timeout, so in that sense there is only one OS timer being used.
Great thx -- that's what I thought I saw in the code :-) Jeff
participants (2)
-
Christopher Kohlhoff
-
Jeff Garland