++ed by:
Author image Leon Timmermans


POSIX::RT::Timer - POSIX real-time timers


version 0.017


 use POSIX::RT::Timer;

 my $timer = POSIX::RT::Timer->new(value => 1, signal => $signo, id => 42);


This module provides for POSIX Real-Time timers. There timers send a signal to the process much like getitimer/setitimer but have various improvements:

  • An arbitrary number of timers is supported.

  • Delivery to any signal is allowed, though using realtime signals is recommended.

  • Time measurement on a variety of clocks is supported.


Class methods

  • 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. This must either be the stringname of a supported clock or a POSIX::RT::Clock object.

    • signal

      The signal number to send a signal to on timer expiration.

    • id

      An integer identifier added to the signal. Do note that perl's default signal handling throws away this information. You'll have to use either unsafe signals, with a risk of crashing your program, or a synchronous signal receiving mechanism (such as POSIX::RT::Signal or Linux::FD::Signal), which may ruin your reason for using timers. YMMV.

Instance methods

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

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

  • handle

    This returns the raw handle to the timer.


Leon Timmermans <fawaka@gmail.com>


This software is copyright (c) 2010 by Leon Timmermans.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.