http://qs321.pair.com?node_id=321784

htoug has asked for the wisdom of the Perl Monks concerning the following question:

I have often had the need to have more than one pending alarm call, but haven't found a (simple) way to do it.

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.
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.

This is quite simple, when you only have to work with one server, alarm does it nicely with a suitable subroutine.

Sys::AlarmCall can handle nested alarm calls (calls to Sys__AlarmCall::alarm_call can be nested and it will call any alarms that were pending when alarm_call was called).

I envision a module that overrides alarm, and "just" ensures that all registered alarms are called at the correct time. The user interface of alarm shouldn't need to change.

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.