Hey Yuval,
Hi.
I'm writing an application that uses many timers in many places. I'd
like to use asio::deadline_timer for this purpose, and an
asio::deadline_timer requires an instance of asio::io_service to
function. The easy way to do it is to create an asio::io_service along
side with each instance of deadline_timer. However, I fear that this is
may be wasteful in terms of OS resources. So my first question is
whether this is true.
If that's true, then I'm not creating an io_service for each
deadline_timer, so I must be sharing a single io_service by several
timers. The problem with such a solution is that the io_service doesn't
know about the timers using it, and especially, it doesn't know how many
such timer there are at any given point in time, and if there are any.
If the number of timers is zero, then there is no work to be done by the
io_service, and the thread calling io_service::run() will be released.
This is bad, because when a new timer will be created, it will require
that there will be a thread calling io_service::run(). So what's the
best solution?