| 1 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Parallel flow model for building creative applications. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package MCE::Flow; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 46 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 46 | ▶ | no warnings qw( threads recursion uninitialized ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 46 | our $VERSION = '1.904'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | ## no critic (BuiltinFunctions::ProhibitStringyEval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ## no critic (Subroutines::ProhibitSubroutinePrototypes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ## no critic (TestingAndDebugging::ProhibitNoStrict) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 46 | ▶ | use Scalar::Util qw( looks_like_number ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 46 | ▶ | use MCE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 46 | our @CARP_NOT = qw( MCE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 46 | ▶ | my $_tid = $INC{'threads.pm'} ? threads->tid() : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub CLONE { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | $_tid = threads->tid() if $INC{'threads.pm'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ## Import routine. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 46 | my ($_MCE, $_def, $_params, $_tag) = ({}, {}, {}, 'MCE::Flow'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 46 | my ($_prev_c, $_prev_n, $_prev_t, $_prev_w) = ({}, {}, {}, {}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 46 | my ($_user_tasks) = ({}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 46 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=13 SCAR=39.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 46 | my ($_class, $_pkg) = (shift, caller); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 46 | my $_p = $_def->{$_pkg} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | MAX_WORKERS => 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | CHUNK_SIZE => 'auto', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ## Import functions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 46 | ▶ | if ($_pkg !~ /^MCE::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 46 | ▶ | no strict 'refs'; no warnings 'redefine'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 46 | *{ $_pkg.'::mce_flow_f' } = \&run_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 46 | *{ $_pkg.'::mce_flow_s' } = \&run_seq; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 46 | *{ $_pkg.'::mce_flow' } = \&run; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | ## Process module arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 46 | ▶ | while ( my $_argument = shift ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my $_arg = lc $_argument; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $_p->{MAX_WORKERS} = shift, next if ( $_arg eq 'max_workers' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | $_p->{CHUNK_SIZE} = shift, next if ( $_arg eq 'chunk_size' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | $_p->{TMP_DIR} = shift, next if ( $_arg eq 'tmp_dir' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $_p->{FREEZE} = shift, next if ( $_arg eq 'freeze' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | $_p->{THAW} = shift, next if ( $_arg eq 'thaw' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | $_p->{INIT_RELAY} = shift, next if ( $_arg eq 'init_relay' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $_p->{USE_THREADS} = shift, next if ( $_arg eq 'use_threads' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | ## Sereal 3.015+, if available, is used automatically by MCE 1.8+. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | if ( $_arg eq 'sereal' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | if ( shift eq '0' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | require Storable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $_p->{FREEZE} = \&Storable::freeze; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $_p->{THAW} = \&Storable::thaw; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | _croak("Error: ($_argument) invalid module option"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 46 | $_p->{MAX_WORKERS} = MCE::_parse_max_workers($_p->{MAX_WORKERS}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 46 | MCE::_validate_number($_p->{MAX_WORKERS}, 'MAX_WORKERS', $_tag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | MCE::_validate_number($_p->{CHUNK_SIZE}, 'CHUNK_SIZE', $_tag) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 46 | ▶ | unless ($_p->{CHUNK_SIZE} eq 'auto'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 46 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ## Init and finish routines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub MCE::Flow::_guard::DESTROY { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($_pkg, $_id) = @{ $_[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (defined $_pkg && $_id eq "$$.$_tid") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_pkg and $_id eq "${$}.$_tid"
MC/DC0%0/2
defined $_pkg and $_id eq "${$}.$_tid"
defined $_pkg
$_id eq "${$}.$_tid"
Truth table0%0/3
A and B
A= defined $_pkgB= $_id eq "${$}.$_tid"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | @{ $_[0] } = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | MCE::Flow->finish($_pkg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 29 | ▶ | sub init (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 29 | ▶ | shift if (defined $_[0] && $_[0] eq 'MCE::Flow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_[0] and $_[0] eq "MCE::Flow"
MC/DC50%1/2
defined $_[0] and $_[0] eq "MCE::Flow"
defined $_[0]
$_[0] eq "MCE::Flow"
Truth table66%2/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Flow"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 29 | my $_pkg = "$$.$_tid.".caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 29 | ▶ | $_params->{$_pkg} = (ref $_[0] eq 'HASH') ? shift : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 29 | @_ = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | defined wantarray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 29 | ▶ | ? bless([$_pkg, "$$.$_tid"], MCE::Flow::_guard::) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 115 | ▶ | sub finish (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 115 | ▶ | shift if (defined $_[0] && $_[0] eq 'MCE::Flow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] eq "MCE::Flow"
MC/DC0%0/2
defined $_[0] and $_[0] eq "MCE::Flow"
defined $_[0]
$_[0] eq "MCE::Flow"
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Flow"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 115 | ▶ | my $_pkg = (defined $_[0]) ? shift : "$$.$_tid.".caller(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 115 | ▶ | if ( $_pkg eq 'MCE' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 46 | for my $_k ( keys %{ $_MCE } ) { MCE::Flow->finish($_k, 1); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | ▶ | elsif ( $_MCE->{$_pkg} && $_MCE->{$_pkg}{_init_pid} eq "$$.$_tid" ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$_MCE->{$_pkg} and $_MCE->{$_pkg}{"_init_pid"} eq "${$}.$_tid"
MC/DC50%1/2
$_MCE->{$_pkg} and $_MCE->{$_pkg}{"_init_pid"} eq "${$}.$_tid"
$_MCE->{$_pkg}
$_MCE->{$_pkg}{"_init_pid"} eq "${$}.$_tid"
Truth table66%2/3
A and B
A= $_MCE->{$_pkg}B= $_MCE->{$_pkg}{"_init_pid"} eq "${$}.$_tid"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 36 | ▶ | $_MCE->{$_pkg}->shutdown(@_) if $_MCE->{$_pkg}{_spawned}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 36 | delete $_user_tasks->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 36 | delete $_prev_c->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 36 | delete $_prev_n->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 36 | delete $_prev_t->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 36 | delete $_prev_w->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 36 | delete $_MCE->{$_pkg}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 115 | @_ = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 115 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ## Parallel flow with MCE -- file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | ▶ | sub run_file (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_file: called CC=21 SCAR=34.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | shift if (defined $_[0] && $_[0] eq 'MCE::Flow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] eq "MCE::Flow"
MC/DC0%0/2
defined $_[0] and $_[0] eq "MCE::Flow"
defined $_[0]
$_[0] eq "MCE::Flow"
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Flow"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 4 | ▶ | my ($_file, $_pos); my $_start_pos = (ref $_[0] eq 'HASH') ? 2 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 4 | my $_pid = "$$.$_tid.".caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 4 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 4 | ▶ | delete $_p->{input_data} if (exists $_p->{input_data}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | ▶ | delete $_p->{sequence} if (exists $_p->{sequence}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $_params->{$_pid} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 4 | for my $_i ($_start_pos .. @_ - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 8 | my $_r = ref $_[$_i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 8 | ▶ | if ($_r eq '' || $_r eq 'SCALAR' || $_r =~ /^(?:GLOB|FileHandle|IO::)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$_r eq "" or $_r eq "SCALAR" or $_r =~ /^(?:GLOB|FileHandle|IO::)/
$_r eq "" or $_r eq "SCALAR"
MC/DC66%2/3
$_r eq "" or $_r eq "SCALAR" or $_r =~ /^(?:GLOB|FileHandle|IO::)/
$_r eq ""
$_r eq "SCALAR"
$_r =~ /^(?:GLOB|FileHandle|IO::)/
Truth table75%3/4
A or B or C
A= $_r eq ""B= $_r eq "SCALAR"C= $_r =~ /^(?:GLOB|FileHandle|IO::)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 4 | $_file = $_[$_i]; $_pos = $_i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 4 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 4 | ▶ | if (defined $_file && ref $_file eq '' && $_file ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
defined $_file and ref $_file eq "" and $_file ne ""
defined $_file and ref $_file eq ""
MC/DC33%1/3
defined $_file and ref $_file eq "" and $_file ne ""
defined $_file
ref $_file eq ""
$_file ne ""
Truth table50%2/4
A and B and C
A= defined $_fileB= ref $_file eq ""C= $_file ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | _croak("$_tag: ($_file) does not exist") unless (-e $_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | ▶ | _croak("$_tag: ($_file) is not readable") unless (-r $_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | _croak("$_tag: ($_file) is not a plain file") unless (-f $_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 2 | $_params->{$_pid}{_file} = $_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | ▶ | elsif (ref $_file eq 'SCALAR' || ref($_file) =~ /^(?:GLOB|FileHandle|IO::)/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_file eq "SCALAR" or ref($_file) =~ /^(?:GLOB|FileHandle|IO::)/
MC/DC0%0/2
ref $_file eq "SCALAR" or ref($_file) =~ /^(?:GLOB|FileHandle|IO::)/
ref $_file eq "SCALAR"
ref($_file) =~ /^(?:GLOB|FileHandle|IO::)/
Truth table33%1/3
A or B
A= ref $_file eq "SCALAR"B= ref($_file) =~ /^(?:GLOB|FileHandle|IO::)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | $_params->{$_pid}{_file} = $_file; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | _croak("$_tag: (file) is not specified or valid"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | ▶ | if (defined $_pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | pop @_ for ($_pos .. @_ - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 4 | return run(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ## Parallel flow with MCE -- sequence. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | sub run_seq (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_seq: called CC=22 SCAR=38.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | ▶ | shift if (defined $_[0] && $_[0] eq 'MCE::Flow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] eq "MCE::Flow"
MC/DC0%0/2
defined $_[0] and $_[0] eq "MCE::Flow"
defined $_[0]
$_[0] eq "MCE::Flow"
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Flow"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | my ($_begin, $_end, $_pos); my $_start_pos = (ref $_[0] eq 'HASH') ? 2 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $_pid = "$$.$_tid.".caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | ▶ | delete $_p->{sequence} if (exists $_p->{sequence}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | delete $_p->{input_data} if (exists $_p->{input_data}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 2 | ▶ | delete $_p->{_file} if (exists $_p->{_file}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $_params->{$_pid} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | for my $_i ($_start_pos .. @_ - 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | my $_r = ref $_[$_i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 4 | ▶ | if ($_r eq '' || $_r =~ /^Math::/ || $_r eq 'HASH' || $_r eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$_r eq "" or $_r =~ /^Math::/ or $_r eq "HASH" or $_r eq "ARRAY"
$_r eq "" or $_r =~ /^Math::/ or $_r eq "HASH"
$_r eq "" or $_r =~ /^Math::/
MC/DC25%1/4
$_r eq "" or $_r =~ /^Math::/ or $_r eq "HASH" or $_r eq "ARRAY"
$_r eq ""
$_r =~ /^Math::/
$_r eq "HASH"
$_r eq "ARRAY"
Truth table40%2/5
A or B or C or D
A= $_r eq ""B= $_r =~ /^Math::/C= $_r eq "HASH"D= $_r eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | $_pos = $_i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | ▶ | if ($_r eq '' || $_r =~ /^Math::/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition33%1/3
$_r eq "" or $_r =~ /^Math::/
MC/DC0%0/2
$_r eq "" or $_r =~ /^Math::/
$_r eq ""
$_r =~ /^Math::/
Truth table33%1/3
A or B
A= $_r eq ""B= $_r =~ /^Math::/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | $_begin = $_[$_pos], $_end = $_[$_pos + 1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $_params->{$_pid}{sequence} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 2 | $_[$_pos], $_[$_pos + 1], $_[$_pos + 2], $_[$_pos + 3] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | elsif ($_r eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $_begin = $_[$_pos]->{begin}, $_end = $_[$_pos]->{end}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $_params->{$_pid}{sequence} = $_[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | elsif ($_r eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $_begin = $_[$_pos]->[0], $_end = $_[$_pos]->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $_params->{$_pid}{sequence} = $_[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | _croak("$_tag: (sequence) is not specified or valid") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | ▶ | unless (exists $_params->{$_pid}{sequence}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | _croak("$_tag: (begin) is not specified for sequence") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | unless (defined $_begin); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | ▶ | _croak("$_tag: (end) is not specified for sequence") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | unless (defined $_end); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | $_params->{$_pid}{sequence_run} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | ▶ | if (defined $_pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | pop @_ for ($_pos .. @_ - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 2 | return run(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ## Parallel flow with MCE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 79 | ▶ | sub run (@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run: called CC=67 SCAR=47.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 79 | my $_caller = caller(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 79 | ▶ | if ($_caller ne 'MCE::Flow' && !exists $_def->{$_caller}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_caller ne "MCE::Flow" and not exists $_def->{$_caller}
MC/DC0%0/2
$_caller ne "MCE::Flow" and not exists $_def->{$_caller}
$_caller ne "MCE::Flow"
not exists $_def->{$_caller}
Truth table66%2/3
A and not(B)
A= $_caller ne "MCE::Flow"B= not exists $_def->{$_caller}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | warn "MCE::Flow is not imported into the \"$_caller\" namespace. Aborting...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 79 | ▶ | shift if (defined $_[0] && $_[0] eq 'MCE::Flow'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and $_[0] eq "MCE::Flow"
MC/DC0%0/2
defined $_[0] and $_[0] eq "MCE::Flow"
defined $_[0]
$_[0] eq "MCE::Flow"
Truth table33%1/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Flow"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 79 | ▶ | my $_pkg = $_caller eq 'MCE::Flow' ? caller(1) : $_caller; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 79 | my $_pid = "$$.$_tid.$_pkg"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 79 | ▶ | if (ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 53 | ▶ | $_params->{$_pid} = {} unless defined $_params->{$_pid}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 53 | for my $_p (keys %{ $_[0] }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 82 | $_params->{$_pid}{$_p} = $_[0]->{$_p}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 53 | shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | ## ------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 79 | my (@_code, @_name, @_thrs, @_wrks); my $_init_mce = 0; my $_pos = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 79 | ▶ | while (ref $_[0] eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 99 | push @_code, $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 99 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | push @_name, (ref $_p->{task_name} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 99 | ▶ | ? $_p->{task_name}->[$_pos] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | push @_thrs, (ref $_p->{use_threads} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 99 | ▶ | ? $_p->{use_threads}->[$_pos] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | push @_wrks, (ref $_p->{max_workers} eq 'ARRAY') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 99 | ▶ | ? $_p->{max_workers}->[$_pos] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | $_init_mce = 1 if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | !defined $_prev_c->{$_pid}[$_pos] || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 99 | ▶ | $_prev_c->{$_pid}[$_pos] != $_code[$_pos] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $_prev_c->{$_pid}[$_pos] or $_prev_c->{$_pid}[$_pos] != $_code[$_pos]
MC/DC50%1/2
not defined $_prev_c->{$_pid}[$_pos] or $_prev_c->{$_pid}[$_pos] != $_code[$_pos]
not defined $_prev_c->{$_pid}[$_pos]
$_prev_c->{$_pid}[$_pos] != $_code[$_pos]
Truth table66%2/3
not(A) or B
A= not defined $_prev_c->{$_pid}[$_pos]B= $_prev_c->{$_pid}[$_pos] != $_code[$_pos]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 99 | ▶ | $_init_mce = 1 if ($_prev_n->{$_pid}[$_pos] ne $_name[$_pos]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 99 | ▶ | $_init_mce = 1 if ($_prev_t->{$_pid}[$_pos] ne $_thrs[$_pos]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 99 | ▶ | $_init_mce = 1 if ($_prev_w->{$_pid}[$_pos] ne $_wrks[$_pos]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 99 | $_prev_c->{$_pid}[$_pos] = $_code[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 99 | $_prev_n->{$_pid}[$_pos] = $_name[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 99 | $_prev_t->{$_pid}[$_pos] = $_thrs[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 99 | $_prev_w->{$_pid}[$_pos] = $_wrks[$_pos]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 99 | shift; $_pos++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 79 | ▶ | if (defined $_prev_c->{$_pid}[$_pos]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | pop @{ $_prev_c->{$_pid} } for ($_pos .. $#{ $_prev_c->{$_pid } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | pop @{ $_prev_n->{$_pid} } for ($_pos .. $#{ $_prev_n->{$_pid } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | pop @{ $_prev_t->{$_pid} } for ($_pos .. $#{ $_prev_t->{$_pid } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | pop @{ $_prev_w->{$_pid} } for ($_pos .. $#{ $_prev_w->{$_pid } }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $_init_mce = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 79 | ▶ | return unless (scalar @_code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ## ------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 79 | my $_input_data; my $_max_workers = $_def->{$_pkg}{MAX_WORKERS}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 79 | my $_r = ref $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 79 | ▶ | if (@_ == 1 && $_r =~ /^(?:ARRAY|HASH|SCALAR|GLOB|FileHandle|IO::|Iterator::)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and $_r =~ /^(?:ARRAY|HASH|SCALAR|GLOB|FileHandle|IO::|Iterator::)/
MC/DC50%1/2
@_ == 1 and $_r =~ /^(?:ARRAY|HASH|SCALAR|GLOB|FileHandle|IO::|Iterator::)/
@_ == 1
$_r =~ /^(?:ARRAY|HASH|SCALAR|GLOB|FileHandle|IO::|Iterator::)/
Truth table66%2/3
A and B
A= @_ == 1B= $_r =~ /^(?:ARRAY|HASH|SCALAR|GLOB|FileHandle|IO::|Iterator::)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | $_input_data = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 79 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | $_max_workers = MCE::_parse_max_workers($_p->{max_workers}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 79 | ▶ | if (exists $_p->{max_workers} && ref $_p->{max_workers} ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $_p->{"max_workers"} and ref $_p->{"max_workers"} ne "ARRAY"
MC/DC50%1/2
exists $_p->{"max_workers"} and ref $_p->{"max_workers"} ne "ARRAY"
exists $_p->{"max_workers"}
ref $_p->{"max_workers"} ne "ARRAY"
Truth table66%2/3
A and B
A= exists $_p->{"max_workers"}B= ref $_p->{"max_workers"} ne "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 79 | ▶ | delete $_p->{sequence} if (defined $_input_data || scalar @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
defined $_input_data or scalar @_
MC/DC100%1/1
defined $_input_data or scalar @_
defined $_input_data
Truth table100%2/2
A
A= defined $_input_data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 79 | ▶ | delete $_p->{user_func} if (exists $_p->{user_func}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 79 | ▶ | delete $_p->{user_tasks} if (exists $_p->{user_tasks}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 79 | ▶ | if (@_code > 1 && $_max_workers > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_code > 1 and $_max_workers > 1
MC/DC50%1/2
@_code > 1 and $_max_workers > 1
@_code > 1
$_max_workers > 1
Truth table66%2/3
A and B
A= @_code > 1B= $_max_workers > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 20 | $_max_workers = int($_max_workers / @_code + 0.5) + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | my $_chunk_size = MCE::_parse_chunk_size( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 79 | $_def->{$_pkg}{CHUNK_SIZE}, $_max_workers, $_params->{$_pid}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | $_input_data, scalar @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 79 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 79 | ▶ | if (exists $_p->{_file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 4 | $_input_data = delete $_p->{_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 75 | ▶ | $_input_data = $_p->{input_data} if exists $_p->{input_data}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ## ------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 79 | MCE::_save_state($_MCE->{$_pid}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 79 | ▶ | if ($_init_mce) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 69 | ▶ | $_MCE->{$_pid}->shutdown() if (defined $_MCE->{$_pid}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ## must clear arrays for nested session to work with Perl < v5.14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 69 | _gen_user_tasks($_pid, [@_code], [@_name], [@_thrs], [@_wrks]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 69 | @_code = @_name = @_thrs = @_wrks = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | my %_opts = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | max_workers => $_max_workers, task_name => $_tag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 69 | user_tasks => $_user_tasks->{$_pid}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 69 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 69 | local $_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 69 | for (keys %{ $_p }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 124 | ▶ | next if ($_ eq 'max_workers' && ref $_p->{max_workers} eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq "max_workers" and ref $_p->{"max_workers"} eq "ARRAY"
MC/DC100%2/2
$_ eq "max_workers" and ref $_p->{"max_workers"} eq "ARRAY"
$_ eq "max_workers"
ref $_p->{"max_workers"} eq "ARRAY"
Truth table100%3/3
A and B
A= $_ eq "max_workers"B= ref $_p->{"max_workers"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 112 | ▶ | next if ($_ eq 'task_name' && ref $_p->{task_name} eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_ eq "task_name" and ref $_p->{"task_name"} eq "ARRAY"
MC/DC50%1/2
$_ eq "task_name" and ref $_p->{"task_name"} eq "ARRAY"
$_ eq "task_name"
ref $_p->{"task_name"} eq "ARRAY"
Truth table66%2/3
A and B
A= $_ eq "task_name"B= ref $_p->{"task_name"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 106 | ▶ | next if ($_ eq 'use_threads' && ref $_p->{use_threads} eq 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$_ eq "use_threads" and ref $_p->{"use_threads"} eq "ARRAY"
MC/DC0%0/2
$_ eq "use_threads" and ref $_p->{"use_threads"} eq "ARRAY"
$_ eq "use_threads"
ref $_p->{"use_threads"} eq "ARRAY"
Truth table33%1/3
A and B
A= $_ eq "use_threads"B= ref $_p->{"use_threads"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 106 | ▶ | next if ($_ eq 'chunk_size'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 106 | ▶ | next if ($_ eq 'input_data'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 106 | ▶ | next if ($_ eq 'sequence_run'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | _croak("$_tag: ($_) is not a valid constructor argument") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 106 | ▶ | unless (exists $MCE::_valid_fields_new{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 106 | $_opts{$_} = $_p->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 69 | for my $_k (qw/ tmp_dir freeze thaw init_relay use_threads /) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | $_opts{$_k} = $_def->{$_pkg}{uc($_k)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 345 | ▶ | if (exists $_def->{$_pkg}{uc($_k)} && !exists $_opts{$_k}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $_def->{$_pkg}{uc $_k} and not exists $_opts{$_k}
MC/DC0%0/2
exists $_def->{$_pkg}{uc $_k} and not exists $_opts{$_k}
exists $_def->{$_pkg}{uc $_k}
not exists $_opts{$_k}
Truth table33%1/3
A and not(B)
A= exists $_def->{$_pkg}{uc $_k}B= not exists $_opts{$_k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 69 | $_MCE->{$_pid} = MCE->new(pkg => $_pkg, %_opts); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | ## Workers may persist after running. Thus, updating the MCE instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | ## These options do not require respawning. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 10 | ▶ | if (defined (my $_p = $_params->{$_pid})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 10 | for my $_k (qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | RS interval stderr_file stdout_file user_error user_output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | job_delay submit_delay on_post_exit on_post_run user_args | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | flush_file flush_stderr flush_stdout gather max_retries | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 160 | ▶ | $_MCE->{$_pid}{$_k} = $_p->{$_k} if (exists $_p->{$_k}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | ## ------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 79 | ▶ | my @_a; my $_wa = wantarray; $_MCE->{$_pid}{gather} = \@_a if (defined $_wa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 79 | ▶ | if (defined $_input_data) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 8 | @_ = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 8 | $_MCE->{$_pid}->process({ chunk_size => $_chunk_size }, $_input_data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 7 | delete $_MCE->{$_pid}{input_data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | elsif (scalar @_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 6 | $_MCE->{$_pid}->process({ chunk_size => $_chunk_size }, \@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 2 | delete $_MCE->{$_pid}{input_data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 65 | ▶ | if (defined $_params->{$_pid} && exists $_params->{$_pid}{sequence}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $_params->{$_pid} and exists $_params->{$_pid}{"sequence"}
MC/DC50%1/2
defined $_params->{$_pid} and exists $_params->{$_pid}{"sequence"}
defined $_params->{$_pid}
exists $_params->{$_pid}{"sequence"}
Truth table66%2/3
A and B
A= defined $_params->{$_pid}B= exists $_params->{$_pid}{"sequence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | $_MCE->{$_pid}->run({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | chunk_size => $_chunk_size, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | sequence => $_params->{$_pid}{sequence} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | }, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | ▶ | if (exists $_params->{$_pid}{sequence_run}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | delete $_params->{$_pid}{sequence_run}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | delete $_params->{$_pid}{sequence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | delete $_MCE->{$_pid}{sequence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 63 | $_MCE->{$_pid}->run({ chunk_size => $_chunk_size }, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 46 | MCE::_restore_state(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 46 | ▶ | delete $_MCE->{$_pid}{gather} if (defined $_wa); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 46 | ▶ | return ((defined $_wa) ? @_a : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | ## Private methods. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub _croak { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | goto &MCE::_croak; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 69 | ▶ | sub _gen_user_tasks { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_gen_user_tasks: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 69 | my ($_pid, $_code_ref, $_name_ref, $_thrs_ref, $_wrks_ref) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 69 | @{ $_user_tasks->{$_pid} } = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 69 | ▶ | for (my $_i = 0; $_i < @{ $_code_ref }; $_i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 81 | push @{ $_user_tasks->{$_pid} }, { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | task_name => $_name_ref->[$_i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | use_threads => $_thrs_ref->[$_i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | max_workers => $_wrks_ref->[$_i], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | user_func => $_code_ref->[$_i] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 69 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 46 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||