blib/lib/Pipeline/Segment/Async.pm

filter: Statementstmt 85.0% 57 / 67 Branchbran 66.6% 8 / 12 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 88.2% 15 / 17 Podpod 88.8% 8 / 9 totaltotal 79.1% 91 / 115 CC 10 SCAR 7.8
CC
10
Cov
80%
reattach
3.4
model
3.3
threading_models
3.0
CRAP 2.2
« blib/lib/Pipeline/Store/ISA.pm ↑ Summary blib/lib/Pipeline/Segment/Async/IThreads.pm »
1 package Pipeline::Segment::Async;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Pipeline::Segment;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Pipeline::Error::AsyncResults;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Pipeline::Segment::Async::Fork;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Pipeline::Segment::Async::IThreads;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 ▶use base qw( Pipeline::Segment );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 1 our $VERSION = "3.12";
14  
15 2 ▶sub init {
Subroutine init: called CC=2 SCAR=7.1
Pod documented
16 2 my $self = shift;
17 2 ▶ if ($self->SUPER::init( @_ )) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->SUPER::init(@_)) 2 0 2
18 2 $self->threading_models(
19 [
20 'Pipeline::Segment::Async::IThreads',
21 'Pipeline::Segment::Async::Fork',
22 ]
23 );
24 }
25 }
26  
27 3 ▶sub threading_models {
Subroutine threading_models: called CC=3 SCAR=11.1
Pod documented
28 3 my $self = shift;
29 3 my $list = shift;
30 3 ▶ if ( defined( $list ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $list) { } 2 1 3
31 2 $self->{ threading_models_available } = $list;
32 2 return $self;
33 } else {
34 1 my $retval = $self->{ threading_models_available };
35 1 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) { } 1 0 1
36 1 return @$retval;
37 } else {
38 0 return $retval;
39 }
40 }
41 }
42  
43 1 ▶sub predispatch {
Subroutine predispatch: called CC=1 SCAR=0.4
Pod documented
44 1 my $self = shift;
45 1 my $sub = $self->can('dispatch');
46 0 ▶ my $outer = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
47 0 my $self = shift;
48 0 my @results = $sub->($self, $self->parent);
49 0 return [$self, [ @results ]];
50 1 };
51 1 $self->model->run( $outer, $self );
52 1 $self->place_in_store();
53 1 return 1;
54 }
55  
56 1 ▶sub place_in_store {
Subroutine place_in_store: called CC=1 SCAR=0.0
Pod undocumented
57 1 my $self = shift;
58 1 $self->store->set( $self );
59 }
60  
61 3 ▶sub model {
Subroutine model: called CC=3 SCAR=12.0
Pod documented
62 3 my $self = shift;
63 3 my $obj = shift;
64 3 ▶ if (defined( $obj )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $obj) { } 0 3 3
65 0 $self->{ threading_model } = $obj;
66 0 return $self;
67 } else {
68 3 ▶ $self->{ threading_model } ||= $self->determine_threading_model();
Condition66%2/3
$self->{"threading_model"} ||= $self->determine_threading_model
l!l&&r!l&&!r
210
MC/DC0%0/2
$self->{"threading_model"} ||= $self->determine_threading_model
$self->{"threading_model"} $self->determine_threading_model
Truth table66%2/3
A ||= B
A= $self->{"threading_model"}B= $self->determine_threading_model
ABresult
1X1
011
000
69 3 return $self->{ threading_model };
70 }
71 }
72  
73 1 ▶sub determine_threading_model {
Subroutine determine_threading_model: called CC=3 SCAR=11.1
Pod documented
74 1 my $self = shift;
75 1 foreach my $model ($self->threading_models) {
76 2 ▶ if ( $model->canop() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($model->canop) 1 1 2
77 1 return $model->new();
78 }
79 }
80 0 return undef;
81 }
82  
83 1 ▶sub reattach {
Subroutine reattach: called CC=3 SCAR=12.3
Pod documented
84 1 my $self = shift;
85 1 my $results = $self->model->reattach;
86 1 ▶ if (defined($results) && ref($results) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $results and ref $results eq 'ARRAY') { } 1 0 1
Condition33%1/3
defined $results and ref $results eq "ARRAY"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $results and ref $results eq "ARRAY"
defined $results ref $results eq "ARRAY"
Truth table33%1/3
A and B
A= defined $resultsB= ref $results eq "ARRAY"
ABresult
0X0
100
111
87 1 return @{ $results->[1] };
88 } else {
89 0 throw Pipeline::Error::AsyncResults;
90 }
91 }
92  
93 0 ▶sub discard {
Subroutine discard: not called CC=1 SCAR=6.9
Pod documented
94 0 my $self = shift;
95 0 $self->model->discard;
96 }
97  
98 1 ▶sub dispatch_method {
Subroutine dispatch_method: called CC=1 SCAR=0.0
Pod documented
99 1 return "predispatch";
100 }
101  
102 1 1;
103  
104 __END__
« blib/lib/Pipeline/Store/ISA.pm ↑ Summary blib/lib/Pipeline/Segment/Async/IThreads.pm »