| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 25 |  |  | 25 |  | 168 | use strict; | 
|  | 25 |  |  |  |  | 63 |  | 
|  | 25 |  |  |  |  | 1236 |  | 
| 2 |  |  |  |  |  |  | package Event::timer; | 
| 3 | 25 |  |  | 25 |  | 178 | use Carp; | 
|  | 25 |  |  |  |  | 45 |  | 
|  | 25 |  |  |  |  | 1384 |  | 
| 4 | 25 |  |  | 25 |  | 139 | use base 'Event::Watcher'; | 
|  | 25 |  |  |  |  | 46 |  | 
|  | 25 |  |  |  |  | 2571 |  | 
| 5 | 25 |  |  | 25 |  | 163 | use vars qw(@ATTRIBUTE); | 
|  | 25 |  |  |  |  | 65 |  | 
|  | 25 |  |  |  |  | 9154 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | @ATTRIBUTE = qw(at hard interval); | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | 'Event::Watcher'->register; | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | sub new { | 
| 12 |  |  |  |  |  |  | #    lock %Event::; | 
| 13 | 46 |  |  | 46 | 0 | 82 | my $class = shift; | 
| 14 | 46 |  |  |  |  | 160 | my %arg = @_; | 
| 15 | 46 |  | 100 |  |  | 1527 | my $o = allocate($class, delete $arg{attach_to} || {}); | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | # deprecated | 
| 18 | 45 |  |  |  |  | 128 | for (qw(at after interval repeat)) { | 
| 19 | 180 | 50 |  |  |  | 433 | if (exists $arg{"e_$_"}) { | 
| 20 | 0 |  |  |  |  | 0 | carp "'e_$_' is renamed to '$_'"; | 
| 21 | 0 |  |  |  |  | 0 | $arg{$_} = delete $arg{"e_$_"}; | 
| 22 |  |  |  |  |  |  | } | 
| 23 |  |  |  |  |  |  | } | 
| 24 |  |  |  |  |  |  |  | 
| 25 | 45 |  |  |  |  | 93 | my $has_at = exists $arg{at}; | 
| 26 | 45 |  |  |  |  | 83 | my $has_after = exists $arg{after}; | 
| 27 |  |  |  |  |  |  |  | 
| 28 | 45 | 50 | 66 |  |  | 117 | croak "'after' and 'at' are mutually exclusive" | 
| 29 |  |  |  |  |  |  | if $has_at && $has_after; | 
| 30 |  |  |  |  |  |  |  | 
| 31 | 45 | 100 |  |  |  | 105 | if ($has_after) { | 
|  |  | 100 |  |  |  |  |  | 
| 32 | 39 |  |  |  |  | 70 | my $after = delete $arg{after}; | 
| 33 | 39 |  |  |  |  | 214 | $o->at(Event::time() + $after); | 
| 34 | 39 |  |  |  |  | 68 | $has_at=1; | 
| 35 | 39 | 100 |  |  |  | 151 | $o->interval($after) if !exists $arg{interval}; | 
| 36 |  |  |  |  |  |  | } elsif ($has_at) { | 
| 37 | 1 |  |  |  |  | 4 | $o->at(delete $arg{at}); | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 45 | 100 |  |  |  | 119 | if (exists $arg{interval}) { | 
| 40 | 3 |  |  |  |  | 7 | my $i = delete $arg{interval}; | 
| 41 | 3 | 50 |  |  |  | 17 | $o->at(Event::time() + (ref $i? $$i : $i)) unless $has_at; | 
|  |  | 100 |  |  |  |  |  | 
| 42 | 3 |  |  |  |  | 13 | $o->interval($i); | 
| 43 | 3 | 50 |  |  |  | 18 | $o->repeat(1) unless exists $arg{repeat}; | 
| 44 |  |  |  |  |  |  | } | 
| 45 |  |  |  |  |  |  |  | 
| 46 | 45 |  |  |  |  | 220 | $o->init(\%arg); | 
| 47 | 43 |  |  |  |  | 141 | $o; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | 1; |