File Coverage

blib/lib/Net/SIP/Dispatcher/AnyEvent/Timer.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 2 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1 27     27   166 use strict;
  27         53  
  27         1237  
2 27     27   158 use warnings;
  27         60  
  27         1725  
3             package Net::SIP::Dispatcher::AnyEvent::Timer;
4             {
5             $Net::SIP::Dispatcher::AnyEvent::Timer::VERSION = '0.002';
6             }
7             # ABSTRACT: A timer object for Net::SIP::Dispatcher::AnyEvent
8              
9 27     27   148 use AnyEvent;
  27         54  
  27         588  
10 27     27   89512 use Net::SIP::Util 'invoke_callback';
  27         1784814  
  27         7006  
11              
12             sub new {
13 35     35 1 140 my $class = shift;
14 35         124 my ( $name, $when, $repeat, $cb ) = @_;
15 35         175 my $self = bless {}, $class;
16              
17             $self->{'timer'} = AE::timer $when, $repeat, sub {
18 499     499   18487737 invoke_callback( $cb, $self );
19 35         774 };
20              
21 35         271 return $self;
22             }
23              
24             sub cancel {
25 17     17 1 4026 my $self = shift;
26 17         413 delete $self->{'timer'};
27             }
28              
29             1;
30              
31              
32              
33             =pod
34              
35             =head1 NAME
36              
37             Net::SIP::Dispatcher::AnyEvent::Timer - A timer object for Net::SIP::Dispatcher::AnyEvent
38              
39             =head1 VERSION
40              
41             version 0.002
42              
43             =head1 DESCRIPTION
44              
45             The timer object L creates when asked for a
46             new timer.
47              
48             =head1 INTERNAL ATTRIBUTES
49              
50             These attributes have no accessors, they are saved as internal keys.
51              
52             =head2 timer
53              
54             The actual timer object
55              
56             =head1 METHODS
57              
58             =head2 new($name, $when, $repeat, $cb_data)
59              
60             A constructor creating the new timer. You set when to start, the callback and
61             how often to repeat.
62              
63             =head2 cancel
64              
65             Cancel the timer.
66              
67             =head1 AUTHOR
68              
69             Sawyer X
70              
71             =head1 COPYRIGHT AND LICENSE
72              
73             This software is copyright (c) 2013 by Sawyer X.
74              
75             This is free software; you can redistribute it and/or modify it under
76             the same terms as the Perl 5 programming language system itself.
77              
78             =cut
79              
80              
81             __END__