| 1 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | package Event::timer; | ||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 25 | ▶ | use base 'Event::Watcher'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 25 | ▶ | use vars qw(@ATTRIBUTE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 25 | @ATTRIBUTE = qw(at hard interval); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 25 | 'Event::Watcher'->register; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 46 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=26.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | # lock %Event::; | ||||||||||||||||||||||||||||
| 13 | 46 | my $class = shift; | |||||||||||||||||||||||||||
| 14 | 46 | my %arg = @_; | |||||||||||||||||||||||||||
| 15 | 46 | ▶ | my $o = allocate($class, delete $arg{attach_to} || {}); | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $arg{'attach_to'} || {}
MC/DC100%1/1
delete $arg{'attach_to'} || {}
delete $arg{'attach_to'}
Truth table100%2/2
A
A= delete $arg{'attach_to'}
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # deprecated | ||||||||||||||||||||||||||||
| 18 | 45 | for (qw(at after interval repeat)) { | |||||||||||||||||||||||||||
| 19 | 180 | ▶ | if (exists $arg{"e_$_"}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 0 | carp "'e_$_' is renamed to '$_'"; | |||||||||||||||||||||||||||
| 21 | 0 | $arg{$_} = delete $arg{"e_$_"}; | |||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 45 | my $has_at = exists $arg{at}; | |||||||||||||||||||||||||||
| 26 | 45 | my $has_after = exists $arg{after}; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 45 | ▶ | croak "'after' and 'at' are mutually exclusive" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$has_at and $has_after
MC/DC0%0/2
$has_at and $has_after
$has_at
$has_after
Truth table66%2/3
A and B
A= $has_atB= $has_after
| |||||||||||||||||||||||||||||
| 29 | if $has_at && $has_after; | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 45 | ▶ | if ($has_after) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 32 | 39 | my $after = delete $arg{after}; | |||||||||||||||||||||||||||
| 33 | 39 | $o->at(Event::time() + $after); | |||||||||||||||||||||||||||
| 34 | 39 | $has_at=1; | |||||||||||||||||||||||||||
| 35 | 39 | ▶ | $o->interval($after) if !exists $arg{interval}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } elsif ($has_at) { | ||||||||||||||||||||||||||||
| 37 | 1 | $o->at(delete $arg{at}); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 45 | ▶ | if (exists $arg{interval}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 3 | my $i = delete $arg{interval}; | |||||||||||||||||||||||||||
| 41 | 3 | ▶ | $o->at(Event::time() + (ref $i? $$i : $i)) unless $has_at; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 42 | 3 | $o->interval($i); | |||||||||||||||||||||||||||
| 43 | 3 | ▶ | $o->repeat(1) unless exists $arg{repeat}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 45 | $o->init(\%arg); | |||||||||||||||||||||||||||
| 47 | 43 | $o; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 25 | 1; | |||||||||||||||||||||||||||