| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition33%1/3
defined $results and ref $results eq "ARRAY"
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"
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||