| 1 | package CHI::Cascade::Target; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Time::HiRes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use Time::Duration::Parse; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | my ($class, %opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=8.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | bless { %opts }, ref($class) || $class; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | sub lock { | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | ▶ | $_[0]->{locked} = $$; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
lock: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | sub locked { | ||||||||||||||||||||||||||||||||||||||||||
| 20 | exists $_[0]->{locked} | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 43 | ▶ | and $_[0]->{locked}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
locked: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | sub unlock { | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | ▶ | delete $_[0]->{locked}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlock: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | sub time { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 36 | ▶ | $_[0]->{time} || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
time: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | sub touch { | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 10 | ▶ | $_[0]->{time} = Time::HiRes::time; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
touch: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | delete $_[0]->{finish_time}; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | delete $_[0]->{expires_finish_time}; | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub actual_stamp { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 3 | ▶ | $_[0]->{actual_stamp} = Time::HiRes::time; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
actual_stamp: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | sub is_actual { | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | ▶ | ( $_[0]->{actual_stamp} || $_[0]->{time} || 0 ) + $_[1] >= Time::HiRes::time; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_actual: called CC=3 SCAR=12.0
Pod
undocumented
Condition60%3/5
$_[0]{'actual_stamp'} || $_[0]{'time'} || 0
$_[0]{"actual_stamp"} or $_[0]{"time"}
MC/DC0%0/2
$_[0]{'actual_stamp'} || $_[0]{'time'} || 0
$_[0]{"actual_stamp"}
$_[0]{"time"}
Truth table66%2/3
A or B
A= $_[0]{"actual_stamp"}B= $_[0]{"time"}
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub ttl { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 25 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ttl: called CC=5 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 25 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | $self->{finish_time} = ( $_[1] || Time::HiRes::time ) + $_[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_[1] || &Time::HiRes::time()
MC/DC0%0/2
$_[1] || &Time::HiRes::time()
$_[1]
&Time::HiRes::time()
Truth table0%0/3
A || B
A= $_[1]B= &Time::HiRes::time()
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 25 | ▶ | return exists $self->{finish_time} && $self->{finish_time} ? $self->{finish_time} - Time::HiRes::time : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $self->{"finish_time"} and $self->{"finish_time"}
MC/DC0%0/2
exists $self->{"finish_time"} and $self->{"finish_time"}
exists $self->{"finish_time"}
$self->{"finish_time"}
Truth table33%1/3
A and B
A= exists $self->{"finish_time"}B= $self->{"finish_time"}
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | sub expires { | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expires: called CC=8 SCAR=28.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 20 | my $expires = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 20 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 10 | ▶ | return $expires | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$expires eq "never" or $expires eq "now"
MC/DC0%0/2
$expires eq "never" or $expires eq "now"
$expires eq "never"
$expires eq "now"
Truth table33%1/3
A or B
A= $expires eq "never"B= $expires eq "now"
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | if $expires eq 'never' || $expires eq 'now'; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->{expires_finish_time} = Time::HiRes::time + parse_duration( $expires ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | return $expires; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 70 | return | ||||||||||||||||||||||||||||||||||||||||||
| 71 | exists $self->{expires_finish_time} && $self->{expires_finish_time} | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ? | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 74 | $self->{expires_finish_time} > Time::HiRes::time | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ? | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | ▶ | int( $self->{expires_finish_time} - Time::HiRes::time + 0.5 ) || 'now' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition20%1/5
exists $self->{"expires_finish_time"} and $self->{"expires_finish_time"}
int $self->{"expires_finish_time"} - &Time::HiRes::time() + "0.5" or "now"
MC/DC0%0/2
exists $self->{"expires_finish_time"} and $self->{"expires_finish_time"}
exists $self->{"expires_finish_time"}
$self->{"expires_finish_time"}
MC/DC0%0/1
int $self->{"expires_finish_time"} - &Time::HiRes::time() + "0.5" or "now"
int $self->{"expires_finish_time"} - &Time::HiRes::time() + "0.5"
Truth table33%1/3
A and B
A= exists $self->{"expires_finish_time"}B= $self->{"expires_finish_time"}
Truth table0%0/2
A
A= int $self->{"expires_finish_time"} - &Time::HiRes::time() + "0.5"
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | : | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 'now' | ||||||||||||||||||||||||||||||||||||||||||
| 79 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 80 | : | ||||||||||||||||||||||||||||||||||||||||||
| 81 | undef; | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||