| 1 | 25 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | package Event::Watcher; | ||||||||||||||||||||||||||||
| 3 | 25 | ▶ | use base 'Exporter'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 25 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 25 | ▶ | use vars qw(@EXPORT_OK @ATTRIBUTE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 25 | @EXPORT_OK = qw(ACTIVE SUSPEND R W E T); | |||||||||||||||||||||||||||
| 7 | 25 | @ATTRIBUTE = qw(cb cbtime desc debug prio reentrant repeat max_cb_tm); | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 127 | ▶ | sub register { | ||||||||||||||||||||||||||
|
Subroutine
register: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 10 | 25 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 127 | my $package = caller; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 127 | my $name = $package; | |||||||||||||||||||||||||||
| 14 | 127 | $name =~ s/^.*:://; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 127 | my $sub = \&{"$package\::new"}; | |||||||||||||||||||||||||||
| 17 | 127 | ▶ | die "can't find $package\::new" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 18 | if !$sub; | ||||||||||||||||||||||||||||
| 19 | 127 | ▶ | *{"Event::".$name} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 5043 | shift; | |||||||||||||||||||||||||||
| 21 | 5043 | $sub->("Event::".$name, @_); | |||||||||||||||||||||||||||
| 22 | 127 | }; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 127 | ▶ | &Event::add_hooks if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 25 | my $warn_noise = 10; | |||||||||||||||||||||||||||
| 28 | 5042 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=17 SCAR=28.7
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 5042 | ▶ | croak "Event::Watcher::init wants 2 args" if @_ != 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 5042 | my ($o, $arg) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 5042 | for my $k (keys %$arg) { | |||||||||||||||||||||||||||
| 33 | 24914 | ▶ | if ($k =~ s/^e_//) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | Carp::cluck "'e_$k' is renamed to '$k'" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | if --$warn_noise >= 0; | ||||||||||||||||||||||||||||
| 36 | 0 | $arg->{$k} = delete $arg->{"e_$k"}; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 5042 | ▶ | if (!exists $arg->{desc}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | # try to find caller but cope with optimized-away frames & etc | ||||||||||||||||||||||||||||
| 42 | 5020 | for my $up (1..4) { | |||||||||||||||||||||||||||
| 43 | 10040 | my @fr = caller $up; | |||||||||||||||||||||||||||
| 44 | 10040 | ▶ | next if !@fr || $fr[0] =~ m/^Event\b/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not @fr or $fr[0] =~ /^Event\b/
MC/DC50%1/2
not @fr or $fr[0] =~ /^Event\b/
not @fr
$fr[0] =~ /^Event\b/
Truth table66%2/3
not(A) or B
A= not @frB= $fr[0] =~ /^Event\b/
| |||||||||||||||||||||||||||||
| 45 | 5020 | my ($file,$line) = @fr[1,2]; | |||||||||||||||||||||||||||
| 46 | 5020 | $file =~ s,^.*/,,; | |||||||||||||||||||||||||||
| 47 | 5020 | $o->desc("?? $file:$line"); | |||||||||||||||||||||||||||
| 48 | 5020 | last; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # set up prio | ||||||||||||||||||||||||||||
| 53 | { | ||||||||||||||||||||||||||||
| 54 | 25 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 55 | 5042 | ▶ | $o->prio($ { ref($o)."::DefaultPriority" } || Event::PRIO_NORMAL()); | ||||||||||||||||||||||||||
|
Condition100%2/2
${ref($o) . '::DefaultPriority';} || 4
MC/DC100%1/1
${ref($o) . '::DefaultPriority';} || 4
${ref($o) . '::DefaultPriority';}
Truth table100%2/2
A
A= ${ref($o) . '::DefaultPriority';}
| |||||||||||||||||||||||||||||
| 56 | 5042 | ▶ | if (exists $arg->{nice}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | 3 | $o->prio($o->prio + delete $arg->{nice}); | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | $o->prio(-1) | ||||||||||||||||||||||||||||
| 61 | 5042 | ▶ | if delete $arg->{async}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | $o->prio(delete $arg->{prio}) | ||||||||||||||||||||||||||||
| 63 | 5042 | ▶ | if exists $arg->{prio}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # is parked? | ||||||||||||||||||||||||||||
| 66 | 5042 | my $parked = delete $arg->{parked}; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 5042 | for my $k (keys %$arg) { | |||||||||||||||||||||||||||
| 69 | 19943 | my $m = $k; | |||||||||||||||||||||||||||
| 70 | 19943 | ▶ | if ($o->can($m)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 14992 | $o->$m($arg->{$k}); | |||||||||||||||||||||||||||
| 72 | 14991 | next; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 5041 | ▶ | Carp::cluck "creating ".ref($o)." desc='".$o->desc."'\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | if $Event::DebugLevel >= 3; | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 5041 | ▶ | $o->start unless $parked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 5033 | $o; | |||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 3 | ▶ | sub attributes { | ||||||||||||||||||||||||||
|
Subroutine
attributes: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 84 | 25 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 3 | my ($o) = @_; | |||||||||||||||||||||||||||
| 86 | 3 | ▶ | my $pk = ref $o? ref $o : $o; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | 3 | @{"$ {pk}::ATTRIBUTE"}, map { attributes($_) } @{"$ {pk}::ISA"}; | |||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 0 | ▶ | sub configure { | ||||||||||||||||||||||||||
|
Subroutine
configure: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $o = shift; | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | if (! @_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | map { $_, $o->$_() } $o->attributes; | |||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||
| 95 | 0 | ▶ | while (my ($k,$v)= splice @_, -2) { $o->$k($v)} | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | 1 # whatever | ||||||||||||||||||||||||||||
| 97 | 0 | } | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 6 | ▶ | sub private { # assumes $self is a HASH ref | ||||||||||||||||||||||||||
|
Subroutine
private: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 102 | 6 | my $pkg = caller; | |||||||||||||||||||||||||||
| 103 | 6 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 2 | $self->{$pkg} = shift | |||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||
| 106 | 4 | $self->{$pkg}; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 3 | ▶ | sub data { # assumes $self is a HASH ref | ||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 111 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 112 | 3 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 113 | $self->{_user_data_} = shift | ||||||||||||||||||||||||||||
| 114 | 1 | } else { | |||||||||||||||||||||||||||
| 115 | 2 | $self->{_user_data_}; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub clump { | ||||||||||||||||||||||||||
|
Subroutine
clump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 120 | 0 | require Carp; | |||||||||||||||||||||||||||
| 121 | 0 | Carp::cluck "clump is deprecated"; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | package Event::Watcher::Tied; | ||||||||||||||||||||||||||||
| 125 | 25 | ▶ | use vars qw(@ISA @ATTRIBUTE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 126 | 25 | @ISA = 'Event::Watcher'; | |||||||||||||||||||||||||||
| 127 | 25 | @ATTRIBUTE = qw(hard at flags); | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 25 | 1; | |||||||||||||||||||||||||||