| 1 | package Command::Runner::Timeout; | ||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use v5.24; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use experimental qw(lexical_subs signatures); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Time::HiRes (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 10 | our $_USE_CLOCK_MONOTONIC = 0; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 10 | my $time; | |||||||||||||||||||||||||||
| 10 | { | ||||||||||||||||||||||||||||
| 11 | 10 | local $SIG{__DIE__} = 'DEFAULT'; | |||||||||||||||||||||||||||
| 12 | 10 | local $@; | |||||||||||||||||||||||||||
| 13 | 10 | ▶ | if (eval 'Time::HiRes::clock_gettime( Time::HiRes::CLOCK_MONOTONIC() )') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 132 | ▶ | $time = sub (@) { Time::HiRes::clock_gettime(Time::HiRes::CLOCK_MONOTONIC()) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 10 | $_USE_CLOCK_MONOTONIC = 1; | |||||||||||||||||||||||||||
| 16 | } else { | ||||||||||||||||||||||||||||
| 17 | 0 | $time = \&Time::HiRes::time; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | sub new ($class, $at, $kill) { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 4 | my $now = $time->(); | |||||||||||||||||||||||||||
| 23 | 4 | bless { signaled => 0, at => $now + $at, at_kill => $now + $at + $kill }, $class; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 128 | ▶ | sub signal ($self) { | ||||||||||||||||||||||||||
|
Subroutine
signal: called CC=6 SCAR=20.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 128 | ▶ | return if !$self->{at} && !$self->{at_kill}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"at"} or $self->{"at_kill"}
MC/DC0%0/2
$self->{"at"} or $self->{"at_kill"}
$self->{"at"}
$self->{"at_kill"}
Truth table33%1/3
A or B
A= $self->{"at"}B= $self->{"at_kill"}
| |||||||||||||||||||||||||||||
| 28 | 128 | my $now = $time->(); | |||||||||||||||||||||||||||
| 29 | 128 | ▶ | if ($self->{at} and $now >= $self->{at}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"at"} and $now >= $self->{"at"}
MC/DC50%1/2
$self->{"at"} and $now >= $self->{"at"}
$self->{"at"}
$now >= $self->{"at"}
Truth table66%2/3
A and B
A= $self->{"at"}B= $now >= $self->{"at"}
| |||||||||||||||||||||||||||||
| 30 | 4 | $self->{at} = undef; | |||||||||||||||||||||||||||
| 31 | 4 | $self->{signaled} = 1; | |||||||||||||||||||||||||||
| 32 | 4 | return 'TERM'; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 124 | ▶ | if ($now >= $self->{at_kill}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | $self->{at_kill} = undef; | |||||||||||||||||||||||||||
| 36 | 0 | $self->{signaled} = 1; | |||||||||||||||||||||||||||
| 37 | 0 | return 'KILL'; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 124 | return; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | sub signaled ($self) { | ||||||||||||||||||||||||||
|
Subroutine
signaled: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 43 | 4 | $self->{signaled}; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 10 | 1; | |||||||||||||||||||||||||||