Fork/Request.pm

filter: Statementstmt 90.9% 30 / 33 Branchbran 43.7% 7 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 9 / 12 Podpod 100% 5 / 5 totaltotal 77.2% 51 / 66 CC 9 SCAR 10.2
CC
9
Cov
76%
started
6.0
_new
4.2
_start
3.1
CRAP 2.8
« Fork/Exit.pm ↑ Summary
1 package Linux::Event::Fork::Request;
2 40 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 40 our $VERSION = '0.007';
7  
8 40 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ▶sub _new ($class, %args) {
Subroutine _new: called CC=4 SCAR=14.5
11 86 ▶ my $fork = delete $args{fork} or croak "fork missing";
Branch: 1 branch
BranchTrueFalseTotal
my $fork = delete $args{"fork"} or croak("fork missing") 0 86 86
12 86 ▶ my $spec = delete $args{spec} or croak "spec missing";
Branch: 1 branch
BranchTrueFalseTotal
my $spec = delete $args{"spec"} or croak("spec missing") 0 86 86
13 86 ▶ croak "unknown args: " . join(", ", sort keys %args) if %args;
Branch: 1 branch
BranchTrueFalseTotal
if %args 0 86 86
14  
15 # Copy the spec now so later mutation by the caller cannot affect queued work.
16 86 my %copy = %$spec;
17  
18 my $self = bless {
19 fork => $fork,
20 spec => \%copy,
21 canceled => 0,
22 started => 0,
23 child => undef,
24 tag => $copy{tag},
25 data => $copy{data},
26 86 }, $class;
27  
28 86 return $self;
29 }
30  
31 8 ▶sub tag ($self) { return $self->{tag} }
Subroutine tag: called CC=1 SCAR=0.0
Pod documented
32 0 ▶sub data ($self) { return $self->{data} }
Subroutine data: not called CC=1 SCAR=6.9
Pod documented
33  
34 0 ▶sub started ($self) { return $self->{started} ? 1 : 0 }
Subroutine started: not called CC=2 SCAR=17.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
$self->{'started'} ? : 0 0 0
35 0 ▶sub child ($self) { return $self->{child} }
Subroutine child: not called CC=1 SCAR=6.9
Pod documented
36  
37 ▶sub cancel ($self) {
Subroutine cancel: called CC=2 SCAR=7.1
Pod documented
38 6 ▶ return 0 if $self->{canceled};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"canceled"} 0 6 6
39 6 $self->{canceled} = 1;
40 6 return 1;
41 }
42  
43 40 ▶sub _canceled ($self) { return $self->{canceled} ? 1 : 0 }
Subroutine _canceled: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$self->{'canceled'} ? : 0 40 40
44  
45 ▶sub _start ($self) {
Subroutine _start: called CC=3 SCAR=11.2
46 32 ▶ return if $self->{canceled};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"canceled"} 0 32 32
47 32 ▶ return if $self->{started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"started"} 0 32 32
48  
49 32 $self->{started} = 1;
50  
51 32 my $child = $self->{fork}->_spawn_now($self->{spec});
52 20 $self->{child} = $child;
53  
54 20 return $child;
55 }
56  
57 40 1;
58  
59 __END__
« Fork/Exit.pm ↑ Summary