POSIX::RT::Timer - POSIX real-time timers
Version 0.008
use POSIX::RT::Timer; my $timer = POSIX::RT::Timer->new(value => 1, callback => sub { my $timer = shift; # do something });
This module provides for timers. Unlike getitimer/setitimer an arbitrary number of timers is supported. There are two kinds of timers: signal timers and callback timers.
Signal timers send a signal to the process, much like itimers. You can specify which signal is sent, using realtime signals is recommended.
Callback timers call a callback on expiration. They are actually implemented by a signal handler on $POSIX::RT::Timer::SIGNO. The value of this variable can be set before loading this module. Callbacks are called with the timer as their only argument.
$POSIX::RT::Timer::SIGNO
new(%options)
Create a new timer. Options include
value = 0
The time in factional seconds for timer expiration. If it is 0 the timer is disarmed.
interval = 0
The value the timer is set to after expiration. If this is set to 0, it is a one-shot timer.
clock = 'realtime'
The type of clock
signal
The signal number to send a signal to on timer expiration.
callback
The callback to call on timer expiration. The callback will receive the timer as its only arguments.
Signal and callback options are mutually exclusive. It is mandatory to set one of these. Signal timers can not be converted into callback timers or reverse.
get_clocks()
Get a list of all supported clocks by their names.
get_timeout()
Get the timeout value. In list context, it also returns the interval value. Note that this value is always relative to the current time.
set_timeout($value, $interval = 0, $abstime = 0)
Set the timer and interval values. If $abstime is true, they are absolute values, otherwise they are relative to the current time. Returns the old value like get_time does.
$abstime
get_time
get_overrun()
Get the overrun count for the timer. The timer overrun count is the number of additional timer expirations that occurred since the signal was sent.
get_callback()
Get the callback function.
set_callback($callback)
Set the callback function.
Leon Timmermans, <leont at cpan.org>
<leont at cpan.org>
Perl can interact weirdly with signals. Beware of the dragons.
POSIX::RT::Timer currently uses an unsafe signal handler for callback handlers.
Please report any bugs or feature requests to bug-posix-rt-timer at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POSIX-RT-Timer. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-posix-rt-timer at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc POSIX::RT::Timer
You can also look for information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=POSIX-RT-Timer
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/POSIX-RT-Timer
CPAN Ratings
http://cpanratings.perl.org/d/POSIX-RT-Timer
Search CPAN
http://search.cpan.org/dist/POSIX-RT-Timer/
Copyright 2010 Leon Timmermans.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install POSIX::RT::Timer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POSIX::RT::Timer
CPAN shell
perl -MCPAN -e shell install POSIX::RT::Timer
For more information on module installation, please visit the detailed CPAN module installation guide.