perlquestion
htoug
I have often had the need to have more than one pending alarm call, but haven't found a (simple) way to do it.<p>
The current use is for an online system, that communicates with one or more of a number of external servers. It is quite expensive to obtain a connection to the server, so it is preferable to do it as seldom as possible (Data::Lazy is a great help there), and the connection should be dropped again (after a reasonable delay) to release ressources.<br>
This is quite easy: when the connection is established set a timer to discconnect after a certain time. At every activity on the connection extend the time before the timer is triggered.<p>
This is quite simple, when you only have to work with one server, <tt>alarm</tt> does it nicely with a suitable subroutine.<p>
<tt>Sys::AlarmCall</tt> can handle nested alarm calls (calls to <tt>Sys__AlarmCall::alarm_call</tt> can be nested and it will call any alarms that were pending when <tt>alarm_call</tt> was called).<p>
I envision a module that overrides alarm, and "just" ensures that all registered alarms are called at the correct time. The user interface of <tt>alarm</tt> shouldn't need to change.<p>
But I have been unable to find a module, that can handle overlapping alarm calls, and before I run out and do it; I would like to either find a module that does it for me or gather any good ideas that the monks have.