| 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
| |||||||||||
| 12 | 86 | ▶ | my $spec = delete $args{spec} or croak "spec missing"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 86 | ▶ | croak "unknown args: " . join(", ", sort keys %args) if %args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 44 | |||||||||||
| 45 | ▶ | sub _start ($self) { | |||||||||
|
Subroutine
_start: called CC=3 SCAR=11.2
| |||||||||||
| 46 | 32 | ▶ | return if $self->{canceled}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | 32 | ▶ | return if $self->{started}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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__ | ||||||||||