Alarm::Concurrent

Alarm::Concurrent is a Perl module that allows multiple, concurrent alarms.
Download

Alarm::Concurrent Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Cory Johns
  • Publisher web site:
  • http://search.cpan.org/~johnsca/libalarm-1.0/lib/Alarm/Concurrent.pm

Alarm::Concurrent Tags


Alarm::Concurrent Description

Alarm::Concurrent is a Perl module that allows multiple, concurrent alarms. Alarm::Concurrent is a Perl module that allows multiple, concurrent alarms.This module is an attempt to enhance Perl's built-in alarm/$SIG{ALRM} functionality.This function, and its associated signal handler, allow you to arrange for your program to receive a SIGALRM signal, which you can then catch and deal with appropriately.Unfortunately, due to the nature of the design of these signals (at the OS level), you can only have one alarm and handler active at any given time. That's where this module comes in.This module allows you to define multiple alarms, each with an associated handler. These alarms are sequenced (in a queue) but concurrent, which means that their order is preserved but they always go off as their set time expires, regardless of the state of the other alarms. (If you'd like to have the alarms only go off in the order you set them, see Alarm::Queued.)To set an alarm, call the setalarm() function with the set time of the alarm and a reference to the subroutine to be called when the alarm goes off. You can then go on with your program and the alarm will be called after the set time has passed.It is also possible to set an alarm that does not have a handler associated with it using Alarm::Concurrent::alarm(). (This function can also be imported into your namespace, in which case it will replace Perl's built-in alarm for your package only.)If an alarm that does not have a handler associated with it goes off, the default handler, pointed to by $Alarm::Concurrent::DEFAULT_HANLDER, is called. You can change the default handler by assigning to this variable.The default $Alarm::Concurrent::DEFAULT_HANDLER simply dies with the message "Alarm clock!n".IMPORT/EXPORTNo methods are exported by default but you can import any of the functions in the FUNCTIONS section.You can also import the special tag :ALL which will import all the functions in the FUNCTIONS section (except Alarm::Concurrent::restore()).OVERRIDEIf you import the special tag :OVERRIDE, this module will override Perl's built-in alarm function for every namespace and it will take over Perl's magic %SIG variable, changing any attempts to read or write $SIG{ALRM} into calls to gethandler() and sethandler(), respectively (reading and writing to other keys in %SIG is unaffected).This can be useful when you are calling code that tries to set its own alarm "the old fashioned way." It can also, however, be dangerous. Overriding alarm is documented and should be stable but taking over %SIG is more risky (see CAVEATS).Note that if you do not override alarm and %SIG, any code you use that sets "legacy alarms" will disable all of your concurrent alarms. You can call Alarm::Concurrent::restore() to reinstall the Alarm::Concurrent handler. This function can not be imported. Requirements: · Perl


Alarm::Concurrent Related Software