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.


In reply to More than one alarm-call at a time by htoug

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.