MCE.pm

filter: Statementstmt 56.5% 623 / 1102 Branchbran 31.8% 248 / 778 Conditioncond 23.3% 89 / 381 MC/DCmcdc 4.3% 9 / 209 Subroutinesub 68.4% 52 / 76 Podpod 0.0% 0 / 20 totaltotal 39.7% 1021 / 2566 CC 554 SCAR 55.0
CC
554
Cov
42%
AUTOLOAD
650.0
sendto
650.0
exit
600.0
CRAP 245.3
« MCE/Core/Input/Handle.pm ↑ Summary MCE/Core/Validation.pm »
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## MCE - Many-Core Engine for Perl providing parallel processing capabilities.
4 ##
5 ###############################################################################
6  
7 package MCE;
8  
9 94 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 94 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 94 ▶no warnings qw( threads recursion uninitialized );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 94 our $VERSION = '1.904';
15  
16 ## no critic (BuiltinFunctions::ProhibitStringyEval)
17 ## no critic (Subroutines::ProhibitSubroutinePrototypes)
18 ## no critic (TestingAndDebugging::ProhibitNoStrict)
19  
20 94 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 94 my ($_has_threads, $_freeze, $_thaw, $_tid, $_oid);
23  
24 94 ▶BEGIN {
Subroutine BEGIN: called CC=12 SCAR=29.9
25 94 local $@;
26  
27 94 ▶ if ( $^O eq 'MSWin32' && ! $INC{'threads.pm'} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($^O eq 'MSWin32' and not $INC{'threads.pm'}) { } 0 94 94
elsif ($INC{'threads.pm'} and not $INC{'threads/shared.pm'}) { } 0 188 188
Condition33%1/3
$^O eq "MSWin32" and not $INC{"threads.pm"}
!ll&&!rl&&r
9400
MC/DC0%0/2
$^O eq "MSWin32" and not $INC{"threads.pm"}
$^O eq "MSWin32" not $INC{"threads.pm"}
Truth table33%1/3
A and not(B)
A= $^O eq "MSWin32"B= not $INC{"threads.pm"}
ABresult
0X0
100
111
28 0 eval 'use threads; use threads::shared;';
29 }
30 ▶ elsif ( $INC{'threads.pm'} && ! $INC{'threads/shared.pm'} ) {
Condition33%1/3
$INC{"threads.pm"} and not $INC{"threads/shared.pm"}
!ll&&!rl&&r
9400
MC/DC0%0/2
$INC{"threads.pm"} and not $INC{"threads/shared.pm"}
$INC{"threads.pm"} not $INC{"threads/shared.pm"}
Truth table33%1/3
A and not(B)
A= $INC{"threads.pm"}B= not $INC{"threads/shared.pm"}
ABresult
0X0
100
111
31 0 eval 'use threads::shared;';
32 }
33  
34 94 ▶ $_has_threads = $INC{'threads.pm'} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$INC{'threads.pm'} ? : 0 94 94
35 94 ▶ $_tid = $_has_threads ? threads->tid() : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_has_threads ? : 0 94 94
36 94 $_oid = "$$.$_tid";
37  
38 94 ▶ if ( $] ge '5.008008' && ! $INC{'PDL.pm'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] ge "5.008008" and not $INC{"PDL.pm"}) 94 0 94
Condition33%1/3
$] ge "5.008008" and not $INC{"PDL.pm"}
!ll&&!rl&&r
0094
MC/DC0%0/2
$] ge "5.008008" and not $INC{"PDL.pm"}
$] ge "5.008008" not $INC{"PDL.pm"}
Truth table33%1/3
A and not(B)
A= $] ge "5.008008"B= not $INC{"PDL.pm"}
ABresult
0X0
100
111
39 94 ▶ eval 'use Sereal::Encoder 3.015; use Sereal::Decoder 3.015;';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
40 94 ▶ if ( ! $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 94 0 94
41 94 my $_encoder_ver = int( Sereal::Encoder->VERSION() );
42 94 my $_decoder_ver = int( Sereal::Decoder->VERSION() );
43 94 ▶ if ( $_encoder_ver - $_decoder_ver == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_encoder_ver - $_decoder_ver == 0) 94 0 94
44 94 $_freeze = \&Sereal::Encoder::encode_sereal;
45 94 $_thaw = \&Sereal::Decoder::decode_sereal;
46 }
47 }
48 }
49  
50 94 ▶ if ( ! defined $_freeze ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_freeze) 0 94 94
51 0 require Storable;
52 0 $_freeze = \&Storable::freeze;
53 0 $_thaw = \&Storable::thaw;
54 }
55 }
56  
57 94 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
58 94 ▶use Scalar::Util qw( looks_like_number refaddr reftype weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
59 94 ▶use Socket qw( SOL_SOCKET SO_RCVBUF );
Subroutine BEGIN: called CC=1 SCAR=0.0
60 94 ▶use Time::HiRes qw( sleep time );
Subroutine BEGIN: called CC=1 SCAR=0.0
61  
62 94 ▶use MCE::Util qw( $LF );
Subroutine BEGIN: called CC=1 SCAR=0.0
63 94 ▶use MCE::Signal ();
Subroutine BEGIN: called CC=1 SCAR=0.0
64 94 ▶use MCE::Mutex ();
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 94 our ($MCE, $RLA, $_que_template, $_que_read_size);
67 94 our (%_valid_fields_new);
68  
69 94 my ($TOP_HDLR, $_is_MSWin32, $_is_winenv, $_prev_mce);
70 94 my (%_valid_fields_task, %_params_allowed_args);
71  
72 94 ▶BEGIN {
Subroutine BEGIN: called CC=6 SCAR=17.9
73 ## Configure pack/unpack template for writing to and from the queue.
74 ## Each entry contains 2 positive numbers: chunk_id & msg_id.
75 ## Check for >= 64-bit, otherwize fall back to machine's word length.
76  
77 94 $_que_template = ( ( log(~0+1) / log(2) ) >= 64 ) ? 'Q2' : 'I2';
78 94 $_que_read_size = length pack($_que_template, 0, 0);
79  
80 ## Attributes used internally.
81 ## _abort_msg _caller _chn _com_lock _dat_lock _mgr_live _rla_data _seed
82 ## _chunk_id _pids _run_mode _single_dim _thrs _tids _task_wid _wid _wuf
83 ## _exiting _exit_pid _last_sref _total_exited _total_running _total_workers
84 ## _send_cnt _sess_dir _spawned _state _status _task _task_id _wrk_status
85 ## _init_pid _init_total_workers _pids_t _pids_w _pids_c _relayed
86 ##
87 ## _bsb_r_sock _bsb_w_sock _com_r_sock _com_w_sock _dat_r_sock _dat_w_sock
88 ## _que_r_sock _que_w_sock _rla_r_sock _rla_w_sock _data_channels
89 ## _lock_chn _mutex_n
90  
91 94 %_valid_fields_new = map { $_ => 1 } qw(
92 max_workers tmp_dir use_threads user_tasks task_end task_name freeze thaw
93 chunk_size input_data sequence job_delay spawn_delay submit_delay RS
94 flush_file flush_stderr flush_stdout stderr_file stdout_file use_slurpio
95 interval user_args user_begin user_end user_func user_error user_output
96 bounds_only gather init_relay on_post_exit on_post_run parallel_io
97 loop_timeout max_retries progress posix_exit
98 );
99 94 %_params_allowed_args = map { $_ => 1 } qw(
100 chunk_size input_data sequence job_delay spawn_delay submit_delay RS
101 flush_file flush_stderr flush_stdout stderr_file stdout_file use_slurpio
102 interval user_args user_begin user_end user_func user_error user_output
103 bounds_only gather init_relay on_post_exit on_post_run parallel_io
104 loop_timeout max_retries progress
105 );
106 94 %_valid_fields_task = map { $_ => 1 } qw(
107 max_workers chunk_size input_data interval sequence task_end task_name
108 bounds_only gather init_relay user_args user_begin user_end user_func
109 RS parallel_io use_slurpio use_threads
110 );
111  
112 94 ▶ $_is_MSWin32 = ( $^O eq 'MSWin32' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 94 94
113 94 ▶ $_is_winenv = ( $^O =~ /mswin|mingw|msys|cygwin/i ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$^O =~ /mswin|mingw|msys|cygwin/i ? : 0 94 94
114  
115 ## Create accessor functions.
116 94 ▶ no strict 'refs'; no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
117  
118 94 for my $_p (qw( chunk_size max_retries max_workers task_name user_args )) {
119 470 ▶ *{ $_p } = sub () {
Subroutine __ANON__: called CC=2 SCAR=6.9
120 99 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 3 96 99
121 99 return $self->{$_p};
122 470 };
123 }
124 94 for my $_p (qw( chunk_id seed task_id task_wid wid )) {
125 470 ▶ *{ $_p } = sub () {
Subroutine __ANON__: called CC=2 SCAR=6.9
126 71 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 70 1 71
127 71 return $self->{"_${_p}"};
128 470 };
129 }
130 94 for my $_p (qw( freeze thaw )) {
131 188 ▶ *{ $_p } = sub () {
Subroutine __ANON__: called CC=2 SCAR=6.9
132 208 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 166 42 208
133 208 return $self->{$_p}(@_);
134 188 };
135 }
136  
137 94 $RLA = {};
138  
139 94 return;
140 }
141  
142 ###############################################################################
143 ## ----------------------------------------------------------------------------
144 ## Import routine.
145 ##
146 ###############################################################################
147  
148 94 ▶use constant { SELF => 0, CHUNK => 1, CID => 2 };
Subroutine BEGIN: called CC=1 SCAR=0.0
149  
150 94 ▶our $_MCE_LOCK : shared = 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
151 94 ▶our $_WIN_LOCK : shared = 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
152  
153 94 my ($_def, $_imported) = ({});
154  
155 116 ▶sub import {
Subroutine import: called CC=15 SCAR=47.7
156 116 my ($_class, $_pkg) = (shift, caller);
157 116 my $_p = $_def->{$_pkg} = {};
158  
159 ## Process module arguments.
160 116 ▶ while ( my $_argument = shift ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_argument = shift()) 0 116 116
161 0 my $_arg = lc $_argument;
162  
163 0 ▶ $_p->{MAX_WORKERS} = shift, next if ( $_arg eq 'max_workers' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "max_workers" 0 0 0
164 0 ▶ $_p->{CHUNK_SIZE} = shift, next if ( $_arg eq 'chunk_size' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "chunk_size" 0 0 0
165 0 ▶ $_p->{TMP_DIR} = shift, next if ( $_arg eq 'tmp_dir' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "tmp_dir" 0 0 0
166 0 ▶ $_p->{FREEZE} = shift, next if ( $_arg eq 'freeze' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "freeze" 0 0 0
167 0 ▶ $_p->{THAW} = shift, next if ( $_arg eq 'thaw' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "thaw" 0 0 0
168 0 ▶ $_p->{INIT_RELAY} = shift, next if ( $_arg eq 'init_relay' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "init_relay" 0 0 0
169 0 ▶ $_p->{USE_THREADS} = shift, next if ( $_arg eq 'use_threads' );
Branch: 1 branch
BranchTrueFalseTotal
if $_arg eq "use_threads" 0 0 0
170  
171 0 ▶ if ( $_arg eq 'export_const' || $_arg eq 'const' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_arg eq "export_const" or $_arg eq "const") 0 0 0
Condition0%0/3
$_arg eq "export_const" or $_arg eq "const"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_arg eq "export_const" or $_arg eq "const"
$_arg eq "export_const" $_arg eq "const"
Truth table0%0/3
A or B
A= $_arg eq "export_const"B= $_arg eq "const"
ABresult
1X1
011
000
172 0 ▶ if ( shift eq '1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift() eq 1) 0 0 0
173 94 ▶ no strict 'refs'; no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
174 0 *{ $_pkg.'::SELF' } = \&SELF;
175 0 *{ $_pkg.'::CHUNK' } = \&CHUNK;
176 0 *{ $_pkg.'::CID' } = \&CID;
177 }
178 0 next;
179 }
180  
181 ## Sereal, if available, is used automatically by MCE 1.800 onwards.
182 0 ▶ if ( $_arg eq 'sereal' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_arg eq "sereal") 0 0 0
183 0 ▶ if ( shift eq '0' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (shift() eq 0) 0 0 0
184 0 require Storable;
185 0 $_p->{FREEZE} = \&Storable::freeze;
186 0 $_p->{THAW} = \&Storable::thaw;
187 }
188 0 next;
189 }
190  
191 0 _croak("Error: ($_argument) invalid module option");
192 }
193  
194 116 ▶ return if $_imported++;
Branch: 1 branch
BranchTrueFalseTotal
if $_imported++ 22 94 116
195  
196 ## Instantiate a module-level instance.
197 94 $MCE = MCE->new( _module_instance => 1, max_workers => 0 );
198  
199 94 return;
200 }
201  
202 ###############################################################################
203 ## ----------------------------------------------------------------------------
204 ## Define constants & variables.
205 ##
206 ###############################################################################
207  
208 94 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
209  
210 # Max data channels. This cannot be greater than 8 on MSWin32.
211 94 DATA_CHANNELS => 8,
212  
213 # Max GC size. Undef variable when exceeding size.
214 MAX_GC_SIZE => 1024 * 1024 * 64,
215  
216 MAX_RECS_SIZE => 8192, # Reads number of records if N <= value
217 # Reads number of bytes if N > value
218  
219 OUTPUT_W_ABT => 'W~ABT', # Worker has aborted
220 OUTPUT_W_DNE => 'W~DNE', # Worker has completed
221 OUTPUT_W_RLA => 'W~RLA', # Worker has relayed
222 OUTPUT_W_EXT => 'W~EXT', # Worker has exited
223 OUTPUT_A_REF => 'A~REF', # Input << Array ref
224 OUTPUT_G_REF => 'G~REF', # Input << Glob ref
225 OUTPUT_H_REF => 'H~REF', # Input << Hash ref
226 OUTPUT_I_REF => 'I~REF', # Input << Iter ref
227 OUTPUT_A_CBK => 'A~CBK', # Callback w/ multiple args
228 OUTPUT_N_CBK => 'N~CBK', # Callback w/ no args
229 OUTPUT_A_GTR => 'A~GTR', # Gather data
230 OUTPUT_O_SND => 'O~SND', # Send >> STDOUT
231 OUTPUT_E_SND => 'E~SND', # Send >> STDERR
232 OUTPUT_F_SND => 'F~SND', # Send >> File
233 OUTPUT_D_SND => 'D~SND', # Send >> File descriptor
234 OUTPUT_B_SYN => 'B~SYN', # Barrier sync - begin
235 OUTPUT_E_SYN => 'E~SYN', # Barrier sync - end
236 OUTPUT_S_IPC => 'S~IPC', # Change to win32 IPC
237 OUTPUT_C_NFY => 'C~NFY', # Chunk ID notification
238 OUTPUT_P_NFY => 'P~NFY', # Progress notification
239 OUTPUT_R_NFY => 'R~NFY', # Relay notification
240 OUTPUT_S_DIR => 'S~DIR', # Make/get sess_dir
241 OUTPUT_T_DIR => 'T~DIR', # Make/get tmp_dir
242 OUTPUT_I_DLY => 'I~DLY', # Interval delay
243  
244 READ_FILE => 0, # Worker reads file handle
245 READ_MEMORY => 1, # Worker reads memory handle
246  
247 REQUEST_ARRAY => 0, # Worker requests next array chunk
248 REQUEST_GLOB => 1, # Worker requests next glob chunk
249 REQUEST_HASH => 2, # Worker requests next hash chunk
250  
251 SENDTO_FILEV1 => 0, # Worker sends to 'file', $a, '/path'
252 SENDTO_FILEV2 => 1, # Worker sends to 'file:/path', $a
253 SENDTO_STDOUT => 2, # Worker sends to STDOUT
254 SENDTO_STDERR => 3, # Worker sends to STDERR
255 SENDTO_FD => 4, # Worker sends to file descriptor
256  
257 WANTS_UNDEF => 0, # Callee wants nothing
258 WANTS_ARRAY => 1, # Callee wants list
259 WANTS_SCALAR => 2, # Callee wants scalar
260 94 };
261  
262 94 my $_mce_count = 0;
263  
264 0 ▶sub CLONE {
Subroutine CLONE: not called CC=2 SCAR=17.9
265 0 ▶ $_tid = threads->tid() if $INC{'threads.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"threads.pm"} 0 0 0
266 }
267  
268 330 ▶sub DESTROY {
Subroutine DESTROY: called CC=7 SCAR=26.5
269 330 ▶ CORE::kill('KILL', $$)
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 and $MCE::Signal::KILLED 0 330 330
Condition33%1/3
$_is_MSWin32 and $MCE::Signal::KILLED
!ll&&!rl&&r
33000
MC/DC0%0/2
$_is_MSWin32 and $MCE::Signal::KILLED
$_is_MSWin32 $MCE::Signal::KILLED
Truth table33%1/3
A and B
A= $_is_MSWin32B= $MCE::Signal::KILLED
ABresult
0X0
100
111
270 if ( $_is_MSWin32 && $MCE::Signal::KILLED );
271  
272 $_[0]->shutdown(1)
273 330 ▶ if ( $_[0] && $_[0]->{_spawned} && $_[0]->{_init_pid} eq "$$.$_tid" &&
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] and $_[0]{"_spawned"} and $_[0]{"_init_pid"} eq "${$}.$_tid" and not $MCE::Signal::KILLED 0 330 330
Condition33%3/9
$_[0] and $_[0]{"_spawned"} and $_[0]{"_init_pid"} eq "${$}.$_tid" and not $MCE::Signal::KILLED
!ll&&!rl&&r
33000
$_[0] and $_[0]{"_spawned"} and $_[0]{"_init_pid"} eq "${$}.$_tid"
!ll&&!rl&&r
33000
$_[0] and $_[0]{"_spawned"}
!ll&&!rl&&r
03300
MC/DC0%0/4
$_[0] and $_[0]{"_spawned"} and $_[0]{"_init_pid"} eq "${$}.$_tid" and not $MCE::Signal::KILLED
$_[0] $_[0]{"_spawned"} $_[0]{"_init_pid"} eq "${$}.$_tid" not $MCE::Signal::KILLED
Truth table20%1/5
A and B and C and not(D)
A= $_[0]B= $_[0]{"_spawned"}C= $_[0]{"_init_pid"} eq "${$}.$_tid"D= not $MCE::Signal::KILLED
ABCDresult
0XXX0
10XX0
110X0
11100
11111
274 !$MCE::Signal::KILLED );
275  
276 330 return;
277 }
278  
279 94 ▶END {
Subroutine END: called CC=5 SCAR=17.5
280 94 ▶ return unless ( defined $MCE );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $MCE::MCE 76 18 94
281  
282 18 ▶ my $_pid = $MCE->{_is_thread} ? $$ .'.'. threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$MCE::MCE->{'_is_thread'} ? : 0 18 18
283 18 ▶ $MCE->exit if ( exists $MCE->{_wuf} && $MCE->{_pid} eq $_pid );
Branch: 1 branch
BranchTrueFalseTotal
if exists $MCE::MCE->{"_wuf"} and $MCE::MCE->{"_pid"} eq $_pid 0 18 18
Condition33%1/3
exists $MCE::MCE->{"_wuf"} and $MCE::MCE->{"_pid"} eq $_pid
!ll&&!rl&&r
1800
MC/DC0%0/2
exists $MCE::MCE->{"_wuf"} and $MCE::MCE->{"_pid"} eq $_pid
exists $MCE::MCE->{"_wuf"} $MCE::MCE->{"_pid"} eq $_pid
Truth table33%1/3
A and B
A= exists $MCE::MCE->{"_wuf"}B= $MCE::MCE->{"_pid"} eq $_pid
ABresult
0X0
100
111
284  
285 18 _end();
286 }
287  
288 91 ▶sub _end {
Subroutine _end: called CC=7 SCAR=19.5
289 91 ▶ MCE::Flow->finish ( 'MCE' ) if $INC{'MCE/Flow.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Flow.pm"} 46 45 91
290 91 ▶ MCE::Grep->finish ( 'MCE' ) if $INC{'MCE/Grep.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Grep.pm"} 4 87 91
291 91 ▶ MCE::Loop->finish ( 'MCE' ) if $INC{'MCE/Loop.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Loop.pm"} 5 86 91
292 91 ▶ MCE::Map->finish ( 'MCE' ) if $INC{'MCE/Map.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Map.pm"} 4 87 91
293 91 ▶ MCE::Step->finish ( 'MCE' ) if $INC{'MCE/Step.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Step.pm"} 12 79 91
294 91 ▶ MCE::Stream->finish ( 'MCE' ) if $INC{'MCE/Stream.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Stream.pm"} 10 81 91
295  
296 91 $MCE = $TOP_HDLR = undef;
297 }
298  
299 ###############################################################################
300 ## ----------------------------------------------------------------------------
301 ## Plugin interface for external modules plugging into MCE, e.g. MCE::Queue.
302 ##
303 ###############################################################################
304  
305 94 my (%_plugin_function, @_plugin_loop_begin, @_plugin_loop_end);
306 94 my (%_plugin_list, @_plugin_worker_init);
307  
308 45 ▶sub _attach_plugin {
Subroutine _attach_plugin: called CC=8 SCAR=21.2
309 45 my $_ext_module = caller;
310  
311 45 ▶ unless (exists $_plugin_list{$_ext_module}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_plugin_list{$_ext_module}) 45 0 45
312 45 $_plugin_list{$_ext_module} = undef;
313  
314 45 my $_ext_output_function = $_[0];
315 45 my $_ext_output_loop_begin = $_[1];
316 45 my $_ext_output_loop_end = $_[2];
317 45 my $_ext_worker_init = $_[3];
318  
319 45 ▶ if (ref $_ext_output_function eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ext_output_function eq "HASH") 45 0 45
320 45 for my $_p (keys %{ $_ext_output_function }) {
321 $_plugin_function{$_p} = $_ext_output_function->{$_p}
322 545 ▶ unless (exists $_plugin_function{$_p});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $_plugin_function{$_p} 545 0 545
323 }
324 }
325  
326 45 ▶ push @_plugin_loop_begin, $_ext_output_loop_begin
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ext_output_loop_begin eq "CODE" 45 0 45
327 if (ref $_ext_output_loop_begin eq 'CODE');
328 45 ▶ push @_plugin_loop_end, $_ext_output_loop_end
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ext_output_loop_end eq "CODE" 45 0 45
329 if (ref $_ext_output_loop_end eq 'CODE');
330 45 ▶ push @_plugin_worker_init, $_ext_worker_init
Branch: 1 branch
BranchTrueFalseTotal
if ref $_ext_worker_init eq "CODE" 35 10 45
331 if (ref $_ext_worker_init eq 'CODE');
332 }
333  
334 45 @_ = ();
335  
336 45 return;
337 }
338  
339 ## Functions for saving and restoring $MCE.
340 ## Called by MCE::{ Flow, Grep, Loop, Map, Step, and Stream }.
341  
342 187 ▶sub _save_state {
Subroutine _save_state: called CC=1 SCAR=0.0
343 187 $_prev_mce = $MCE; $MCE = $_[0];
344 187 return;
345 }
346 130 ▶sub _restore_state {
Subroutine _restore_state: called CC=1 SCAR=0.0
347 130 $_prev_mce->{_wrk_status} = $MCE->{_wrk_status};
348 130 $MCE = $_prev_mce; $_prev_mce = undef;
349 130 return;
350 }
351  
352 ###############################################################################
353 ## ----------------------------------------------------------------------------
354 ## New instance instantiation.
355 ##
356 ###############################################################################
357  
358 0 ▶sub _croak {
Subroutine _croak: not called CC=3 SCAR=24.8
359 0 ▶ if (MCE->wid == 0 || ! $^S) {
Branch: 1 branch
BranchTrueFalseTotal
if ("MCE"->wid == 0 or not $^S) 0 0 0
Condition0%0/3
"MCE"->wid == 0 or not $^S
l!l&&r!l&&!r
000
MC/DC0%0/2
"MCE"->wid == 0 or not $^S
"MCE"->wid == 0 not $^S
Truth table0%0/3
A or not(B)
A= "MCE"->wid == 0B= not $^S
ABresult
1X1
011
000
360 0 $SIG{__DIE__} = \&MCE::Signal::_die_handler;
361 0 $SIG{__WARN__} = \&MCE::Signal::_warn_handler;
362 }
363 0 $\ = undef; goto &Carp::croak;
364 }
365  
366 0 ▶sub _relay (;&) {
Subroutine _relay: not called CC=1 SCAR=6.9
367 0 goto &MCE::relay;
368 }
369  
370 94 ▶use MCE::Core::Validation ();
Subroutine BEGIN: called CC=1 SCAR=0.0
371 94 ▶use MCE::Core::Manager ();
Subroutine BEGIN: called CC=1 SCAR=0.0
372 94 ▶use MCE::Core::Worker ();
Subroutine BEGIN: called CC=1 SCAR=0.0
373  
374 342 ▶sub new {
Subroutine new: called CC=63 SCAR=55.4
Pod undocumented
375 342 my ($class, %self) = @_;
376 342 ▶ my $_pkg = exists $self{pkg} ? delete $self{pkg} : caller;
Branch: 1 branch
BranchTrueFalseTotal
exists $self{'pkg'} ? : 108 234 342
377  
378 342 @_ = ();
379  
380 342 ▶ bless(\%self, ref($class) || $class);
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
03420
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
381  
382 342 ▶ $self{task_name} ||= 'MCE';
Condition100%2/2
$self{"task_name"} ||= "MCE"
l!l
108234
MC/DC100%1/1
$self{"task_name"} ||= "MCE"
$self{"task_name"}
Truth table100%2/2
A
A= $self{"task_name"}
Aresult
11
00
383 342 ▶ $self{max_workers} ||= $_def->{$_pkg}{MAX_WORKERS} || 1;
Condition60%3/5
$self{"max_workers"} ||= $_def->{$_pkg}{"MAX_WORKERS"} || 1
l!l&&r!l&&!r
2301120
$_def->{$_pkg}{'MAX_WORKERS'} || 1
l!l
0112
MC/DC0%0/2
$self{"max_workers"} ||= $_def->{$_pkg}{"MAX_WORKERS"} || 1
$self{"max_workers"} $_def->{$_pkg}{'MAX_WORKERS'}
Truth table33%1/3
A ||= B
A= $self{"max_workers"}B= $_def->{$_pkg}{'MAX_WORKERS'}
ABresult
1X1
011
000
384 342 ▶ $self{chunk_size} ||= $_def->{$_pkg}{CHUNK_SIZE} || 1;
Condition40%2/5
$self{"chunk_size"} ||= $_def->{$_pkg}{"CHUNK_SIZE"} || 1
l!l&&r!l&&!r
03420
$_def->{$_pkg}{'CHUNK_SIZE'} || 1
l!l
0342
MC/DC0%0/2
$self{"chunk_size"} ||= $_def->{$_pkg}{"CHUNK_SIZE"} || 1
$self{"chunk_size"} $_def->{$_pkg}{'CHUNK_SIZE'}
Truth table0%0/3
A ||= B
A= $self{"chunk_size"}B= $_def->{$_pkg}{'CHUNK_SIZE'}
ABresult
1X1
011
000
385 342 ▶ $self{tmp_dir} ||= $_def->{$_pkg}{TMP_DIR} || $MCE::Signal::tmp_dir;
Condition66%4/6
$self{"tmp_dir"} ||= $_def->{$_pkg}{"TMP_DIR"} || $MCE::Signal::tmp_dir
l!l&&r!l&&!r
045297
$_def->{$_pkg}{'TMP_DIR'} || $MCE::Signal::tmp_dir
l!l&&r!l&&!r
045297
MC/DC0%0/3
$self{"tmp_dir"} ||= $_def->{$_pkg}{"TMP_DIR"} || $MCE::Signal::tmp_dir
$self{"tmp_dir"} $_def->{$_pkg}{'TMP_DIR'} $MCE::Signal::tmp_dir
Truth table0%0/4
A ||= B || C
A= $self{"tmp_dir"}B= $_def->{$_pkg}{'TMP_DIR'}C= $MCE::Signal::tmp_dir
ABCresult
1XX1
01X1
0011
0000
386 342 ▶ $self{freeze} ||= $_def->{$_pkg}{FREEZE} || $_freeze;
Condition33%2/6
$self{"freeze"} ||= $_def->{$_pkg}{"FREEZE"} || $_freeze
l!l&&r!l&&!r
03420
$_def->{$_pkg}{'FREEZE'} || $_freeze
l!l&&r!l&&!r
03420
MC/DC0%0/3
$self{"freeze"} ||= $_def->{$_pkg}{"FREEZE"} || $_freeze
$self{"freeze"} $_def->{$_pkg}{'FREEZE'} $_freeze
Truth table0%0/4
A ||= B || C
A= $self{"freeze"}B= $_def->{$_pkg}{'FREEZE'}C= $_freeze
ABCresult
1XX1
01X1
0011
0000
387 342 ▶ $self{thaw} ||= $_def->{$_pkg}{THAW} || $_thaw;
Condition33%2/6
$self{"thaw"} ||= $_def->{$_pkg}{"THAW"} || $_thaw
l!l&&r!l&&!r
03420
$_def->{$_pkg}{'THAW'} || $_thaw
l!l&&r!l&&!r
03420
MC/DC0%0/3
$self{"thaw"} ||= $_def->{$_pkg}{"THAW"} || $_thaw
$self{"thaw"} $_def->{$_pkg}{'THAW'} $_thaw
Truth table0%0/4
A ||= B || C
A= $self{"thaw"}B= $_def->{$_pkg}{'THAW'}C= $_thaw
ABCresult
1XX1
01X1
0011
0000
388  
389 $self{init_relay} = $_def->{$_pkg}{INIT_RELAY}
390 342 ▶ if (exists $_def->{$_pkg}{INIT_RELAY});
Branch: 1 branch
BranchTrueFalseTotal
if exists $_def->{$_pkg}{"INIT_RELAY"} 0 342 342
391  
392 $self{use_threads} = $_def->{$_pkg}{USE_THREADS}
393 342 ▶ if (exists $_def->{$_pkg}{USE_THREADS});
Branch: 1 branch
BranchTrueFalseTotal
if exists $_def->{$_pkg}{"USE_THREADS"} 0 342 342
394  
395 342 ▶ if (exists $self{_module_instance}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self{"_module_instance"}) 94 248 342
396 94 $self{_init_total_workers} = $self{max_workers};
397 94 $self{_chunk_id} = $self{_task_wid} = $self{_wrk_status} = 0;
398 94 $self{_spawned} = $self{_task_id} = $self{_wid} = 0;
399 94 $self{_init_pid} = "$$.$_tid";
400  
401 94 return \%self;
402 }
403  
404 248 _sendto_fhs_close();
405  
406 248 for my $_p (keys %self) {
407 _croak("MCE::new: ($_p) is not a valid constructor argument")
408 1758 ▶ unless (exists $_valid_fields_new{$_p});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $MCE::_valid_fields_new{$_p} 0 1758 1758
409 }
410  
411 248 $self{_caller} = $_pkg, $self{_init_pid} = "$$.$_tid";
412  
413 248 ▶ if (defined $self{use_threads}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self{'use_threads'}) { } 0 248 248
414 0 ▶ if (!$_has_threads && $self{use_threads}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_has_threads and $self{"use_threads"}) 0 0 0
Condition0%0/3
not $_has_threads and $self{"use_threads"}
!ll&&!rl&&r
000
MC/DC0%0/2
not $_has_threads and $self{"use_threads"}
not $_has_threads $self{"use_threads"}
Truth table0%0/3
not(A) and B
A= not $_has_threadsB= $self{"use_threads"}
ABresult
0X0
100
111
415 0 my $_msg = "\n";
416 0 $_msg .= "## Please include threads support prior to loading MCE\n";
417 0 $_msg .= "## when specifying use_threads => $self{use_threads}\n";
418 0 $_msg .= "\n";
419  
420 0 _croak($_msg);
421 }
422 }
423 else {
424 248 ▶ $self{use_threads} = ($_has_threads) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_has_threads ? : 0 248 248
425 }
426  
427 248 ▶ if (!exists $self{posix_exit}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self{"posix_exit"}) 248 0 248
428 $self{posix_exit} = 1 if (
429 $^S || $_tid || $INC{'Mojo/IOLoop.pm'} ||
430 $INC{'Coro.pm'} || $INC{'LWP/UserAgent.pm'} || $INC{'stfl.pm'} ||
431 $INC{'Curses.pm'} || $INC{'CGI.pm'} || $INC{'FCGI.pm'} ||
432 $INC{'Tk.pm'} || $INC{'Wx.pm'} || $INC{'Win32/GUI.pm'} ||
433 248 ▶ $INC{'Gearman/Util.pm'} || $INC{'Gearman/XS.pm'}
Branch: 1 branch
BranchTrueFalseTotal
if $^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Gearman/XS.pm"} 0 248 248
Condition33%13/39
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Gearman/XS.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/Util.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"} or $INC{"Win32/GUI.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid or $INC{"Mojo/IOLoop.pm"}
l!l&&r!l&&!r
00248
$^S or $_tid
l!l&&r!l&&!r
00248
MC/DC0%0/14
$^S or $_tid or $INC{"Mojo/IOLoop.pm"} or $INC{"Coro.pm"} or $INC{"LWP/UserAgent.pm"} or $INC{"stfl.pm"} or $INC{"Curses.pm"} or $INC{"CGI.pm"} or $INC{"FCGI.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Gearman/XS.pm"}
$^S $_tid $INC{"Mojo/IOLoop.pm"} $INC{"Coro.pm"} $INC{"LWP/UserAgent.pm"} $INC{"stfl.pm"} $INC{"Curses.pm"} $INC{"CGI.pm"} $INC{"FCGI.pm"} $INC{"Tk.pm"} $INC{"Wx.pm"} $INC{"Win32/GUI.pm"} $INC{"Gearman/Util.pm"} $INC{"Gearman/XS.pm"}
Truth table6%1/15
A or B or C or D or E or F or G or H or I or J or K or L or M or N
A= $^SB= $_tidC= $INC{"Mojo/IOLoop.pm"}D= $INC{"Coro.pm"}E= $INC{"LWP/UserAgent.pm"}F= $INC{"stfl.pm"}G= $INC{"Curses.pm"}H= $INC{"CGI.pm"}I= $INC{"FCGI.pm"}J= $INC{"Tk.pm"}K= $INC{"Wx.pm"}L= $INC{"Win32/GUI.pm"}M= $INC{"Gearman/Util.pm"}N= $INC{"Gearman/XS.pm"}
ABCDEFGHIJKLMNresult
1XXXXXXXXXXXXX1
01XXXXXXXXXXXX1
001XXXXXXXXXXX1
0001XXXXXXXXXX1
00001XXXXXXXXX1
000001XXXXXXXX1
0000001XXXXXXX1
00000001XXXXXX1
000000001XXXXX1
0000000001XXXX1
00000000001XXX1
000000000001XX1
0000000000001X1
000000000000011
000000000000000
434 );
435 }
436  
437 ## -------------------------------------------------------------------------
438 ## Validation.
439  
440 248 ▶ if (defined $self{tmp_dir}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self{"tmp_dir"}) 42 206 248
441 _croak("MCE::new: ($self{tmp_dir}) is not a directory or does not exist")
442 42 ▶ unless (-d $self{tmp_dir});
Branch: 1 branch
BranchTrueFalseTotal
unless -d $self{"tmp_dir"} 0 42 42
443 _croak("MCE::new: ($self{tmp_dir}) is not writeable")
444 42 ▶ unless (-w $self{tmp_dir});
Branch: 1 branch
BranchTrueFalseTotal
unless -w $self{"tmp_dir"} 0 42 42
445 }
446  
447 248 ▶ if (defined $self{user_tasks}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self{"user_tasks"}) 108 140 248
448 _croak('MCE::new: (user_tasks) is not an ARRAY reference')
449 108 ▶ unless (ref $self{user_tasks} eq 'ARRAY');
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self{"user_tasks"} eq "ARRAY" 0 108 108
450  
451 108 $self{max_workers} = _parse_max_workers($self{max_workers});
452 $self{init_relay} = $self{user_tasks}->[0]->{init_relay}
453 108 ▶ if ($self{user_tasks}->[0]->{init_relay});
Branch: 1 branch
BranchTrueFalseTotal
if $self{"user_tasks"}[0]{"init_relay"} 0 108 108
454  
455 108 for my $_task (@{ $self{user_tasks} }) {
456 164 for my $_p (keys %{ $_task }) {
457 _croak("MCE::new: ($_p) is not a valid task constructor argument")
458 548 ▶ unless (exists $_valid_fields_task{$_p});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $_valid_fields_task{$_p} 0 548 548
459 }
460 164 ▶ $_task->{max_workers} = 0 unless scalar(keys %{ $_task });
Branch: 1 branch
BranchTrueFalseTotal
unless scalar keys %{$_task;} 0 164 164
461  
462 $_task->{max_workers} = $self{max_workers}
463 164 ▶ unless (defined $_task->{max_workers});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_task->{"max_workers"} 64 100 164
464 $_task->{use_threads} = $self{use_threads}
465 164 ▶ unless (defined $_task->{use_threads});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_task->{"use_threads"} 164 0 164
466  
467 164 ▶ bless($_task, ref(\%self) || \%self);
Condition50%1/2
ref \%self || \%self
l!l
1640
MC/DC0%0/1
ref \%self || \%self
ref \%self
Truth table50%1/2
A
A= ref \%self
Aresult
11
00
468 }
469 }
470  
471 248 _validate_args(\%self);
472  
473 ## -------------------------------------------------------------------------
474 ## Private options. Limit chunk_size.
475  
476 248 my $_run_lock;
477  
478 248 $self{_chunk_id} = 0; # Chunk ID
479 248 $self{_send_cnt} = 0; # Number of times data was sent via send
480 248 $self{_spawned} = 0; # Have workers been spawned
481 248 $self{_task_id} = 0; # Task ID, starts at 0 (array index)
482 248 $self{_task_wid} = 0; # Task Worker ID, starts at 1 per task
483 248 $self{_wid} = 0; # Worker ID, starts at 1 per MCE instance
484 248 $self{_wrk_status} = 0; # For saving exit status when worker exits
485  
486 248 ▶ $self{_run_lock} = threads::shared::share($_run_lock) if $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 0 248 248
487  
488 $self{_last_sref} = (ref $self{input_data} eq 'SCALAR')
489 248 ▶ ? refaddr($self{input_data}) : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $self{'input_data'} eq 'SCALAR' ? : 0 248 248
490  
491 my $_data_channels = ("$$.$_tid" eq $_oid)
492 248 ▶ ? ( $INC{'MCE/Channel.pm'} ? 4 : DATA_CHANNELS )
Branch: 2 branches
BranchTrueFalseTotal
"${$}.$_tid" eq $_oid ? : 248 0 248
$INC{'MCE/Channel.pm'} ? : 0 248 248
493 : 2;
494  
495 248 my $_total_workers = 0;
496  
497 248 ▶ if (defined $self{user_tasks}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self{'user_tasks'}) { } 108 140 248
498 108 $_total_workers += $_->{max_workers} for @{ $self{user_tasks} };
499 } else {
500 140 $_total_workers = $self{max_workers};
501 }
502  
503 248 $self{_init_total_workers} = $_total_workers;
504  
505 248 ▶ $self{_data_channels} = ($_total_workers < $_data_channels)
Branch: 1 branch
BranchTrueFalseTotal
$_total_workers < $_data_channels ? : 200 48 248
506 ? $_total_workers : $_data_channels;
507  
508 248 ▶ $self{_lock_chn} = ($_total_workers > $self{_data_channels}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_total_workers > $self{'_data_channels'} ? : 42 206 248
509 248 ▶ $self{_lock_chn} = 1 if $INC{'MCE/Child.pm'} || $INC{'MCE/Hobo.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Child.pm"} or $INC{"MCE/Hobo.pm"} 0 248 248
Condition33%1/3
$INC{"MCE/Child.pm"} or $INC{"MCE/Hobo.pm"}
l!l&&r!l&&!r
00248
MC/DC0%0/2
$INC{"MCE/Child.pm"} or $INC{"MCE/Hobo.pm"}
$INC{"MCE/Child.pm"} $INC{"MCE/Hobo.pm"}
Truth table33%1/3
A or B
A= $INC{"MCE/Child.pm"}B= $INC{"MCE/Hobo.pm"}
ABresult
1X1
011
000
510  
511 248 ▶ if ($MCE->{_wid} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MCE::MCE->{"_wid"} == 0) 248 0 248
512 248 $MCE = \%self;
513 248 ▶ weaken $MCE if (defined wantarray);
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray 248 0 248
514 }
515  
516 248 return \%self;
517 }
518  
519 ###############################################################################
520 ## ----------------------------------------------------------------------------
521 ## Spawn method.
522 ##
523 ###############################################################################
524  
525 140 ▶sub spawn {
Subroutine spawn: called CC=67 SCAR=60.4
Pod undocumented
526 140 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 140 140
527  
528 140 local $_; @_ = ();
529  
530 _croak('MCE::spawn: method is not allowed by the worker process')
531 140 ▶ if ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 140 140
532  
533 ## Return if workers have already been spawned or if module instance.
534 140 ▶ return $self if ($self->{_spawned} || exists $self->{_module_instance});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_spawned"} or exists $self->{"_module_instance"} 0 140 140
Condition33%1/3
$self->{"_spawned"} or exists $self->{"_module_instance"}
l!l&&r!l&&!r
00140
MC/DC0%0/2
$self->{"_spawned"} or exists $self->{"_module_instance"}
$self->{"_spawned"} exists $self->{"_module_instance"}
Truth table33%1/3
A or B
A= $self->{"_spawned"}B= exists $self->{"_module_instance"}
ABresult
1X1
011
000
535  
536 140 ▶ lock $_WIN_LOCK if $_is_MSWin32; # Obtain locks
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 0 140 140
537 140 ▶ lock $_MCE_LOCK if $_has_threads && $_is_winenv;
Branch: 1 branch
BranchTrueFalseTotal
if $_has_threads and $_is_winenv 0 140 140
Condition33%1/3
$_has_threads and $_is_winenv
!ll&&!rl&&r
14000
MC/DC0%0/2
$_has_threads and $_is_winenv
$_has_threads $_is_winenv
Truth table33%1/3
A and B
A= $_has_threadsB= $_is_winenv
ABresult
0X0
100
111
538  
539 140 ▶ $MCE::_GMUTEX->lock() if ($_tid && $MCE::_GMUTEX);
Branch: 1 branch
BranchTrueFalseTotal
if $_tid and $MCE::_GMUTEX 0 140 140
Condition33%1/3
$_tid and $MCE::_GMUTEX
!ll&&!rl&&r
14000
MC/DC0%0/2
$_tid and $MCE::_GMUTEX
$_tid $MCE::_GMUTEX
Truth table33%1/3
A and B
A= $_tidB= $MCE::_GMUTEX
ABresult
0X0
100
111
540 140 ▶ sleep 0.015 if $_tid;
Branch: 1 branch
BranchTrueFalseTotal
if $_tid 0 140 140
541  
542 140 _sendto_fhs_close();
543  
544 0 ▶ if ($INC{'PDL.pm'}) { local $@;
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"PDL.pm"}) 0 140 140
545 # PDL::IO::Storable is required for serializing piddles.
546 0 ▶ eval 'use PDL::IO::Storable' unless $INC{'PDL/IO/Storable.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"PDL/IO/Storable.pm"} 0 0 0
547 # PDL data should not be naively copied in new threads.
548 0 eval 'no warnings; sub PDL::CLONE_SKIP { 1 }';
549 # Disable PDL auto-threading.
550 0 eval q{ PDL::set_autopthread_targ(1) };
551 }
552 140 ▶ if ( $INC{'LWP/UserAgent.pm'} && !$INC{'Net/HTTP.pm'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"LWP/UserAgent.pm"} and not $INC{"Net/HTTP.pm"}) 0 140 140
Condition33%1/3
$INC{"LWP/UserAgent.pm"} and not $INC{"Net/HTTP.pm"}
!ll&&!rl&&r
14000
MC/DC0%0/2
$INC{"LWP/UserAgent.pm"} and not $INC{"Net/HTTP.pm"}
$INC{"LWP/UserAgent.pm"} not $INC{"Net/HTTP.pm"}
Truth table33%1/3
A and not(B)
A= $INC{"LWP/UserAgent.pm"}B= not $INC{"Net/HTTP.pm"}
ABresult
0X0
100
111
553 0 local $@; eval 'require Net::HTTP; require Net::HTTPS';
554 }
555  
556 ## Start the shared-manager process if not running.
557 140 ▶ MCE::Shared->start() if $INC{'MCE/Shared.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared.pm"} 0 140 140
558  
559 ## Load input module.
560 140 ▶ if (defined $self->{sequence}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'sequence'}) { } 0 140 140
elsif (defined $self->{'input_data'}) { } 54 86 140
561 require MCE::Core::Input::Sequence
562 0 ▶ unless $INC{'MCE/Core/Input/Sequence.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Core/Input/Sequence.pm"} 0 0 0
563 }
564 elsif (defined $self->{input_data}) {
565 54 my $_ref = ref $self->{input_data};
566 54 ▶ if ($_ref =~ /^(?:ARRAY|HASH|GLOB|FileHandle|IO::)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_ref =~ /^(?:ARRAY|HASH|GLOB|FileHandle|IO::)/) { } 54 0 54
elsif ($_ref =~ /^(?:CODE|Iterator::)/) { } 0 0 0
567 require MCE::Core::Input::Request
568 54 ▶ unless $INC{'MCE/Core/Input/Request.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Core/Input/Request.pm"} 43 11 54
569 }
570 elsif ($_ref =~ /^(?:CODE|Iterator::)/) {
571 require MCE::Core::Input::Iterator
572 0 ▶ unless $INC{'MCE/Core/Input/Iterator.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Core/Input/Iterator.pm"} 0 0 0
573 }
574 else {
575 require MCE::Core::Input::Handle
576 0 ▶ unless $INC{'MCE/Core/Input/Handle.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Core/Input/Handle.pm"} 0 0 0
577 }
578 }
579  
580 140 my $_die_handler = $SIG{__DIE__};
581 140 my $_warn_handler = $SIG{__WARN__};
582  
583 140 $SIG{__DIE__} = \&MCE::Signal::_die_handler;
584 140 $SIG{__WARN__} = \&MCE::Signal::_warn_handler;
585  
586 140 ▶ if (!defined $TOP_HDLR || (!$TOP_HDLR->{_mgr_live} && !$TOP_HDLR->{_wid})) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $TOP_HDLR && ($TOP_HDLR->{'_mgr_live'} || $TOP_HDLR->{'_wid'})) { } 140 0 140
elsif (builtin::refaddr($self) != builtin::refaddr($TOP_HDLR)) { } 0 0 0
Condition16%1/6
defined $TOP_HDLR && ($TOP_HDLR->{'_mgr_live'} || $TOP_HDLR->{'_wid'})
!ll&&!rl&&r
14000
$TOP_HDLR->{"_mgr_live"} or $TOP_HDLR->{"_wid"}
l!l&&r!l&&!r
000
MC/DC0%0/3
defined $TOP_HDLR && ($TOP_HDLR->{'_mgr_live'} || $TOP_HDLR->{'_wid'})
defined $TOP_HDLR $TOP_HDLR->{"_mgr_live"} $TOP_HDLR->{"_wid"}
Truth table25%1/4
A && B or C
A= defined $TOP_HDLRB= $TOP_HDLR->{"_mgr_live"}C= $TOP_HDLR->{"_wid"}
ABCresult
0XX0
1000
11X1
1011
587 ## On Windows, must shutdown the last idle MCE session.
588 140 ▶ if ($_is_MSWin32 && defined $TOP_HDLR && $TOP_HDLR->{_spawned}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_MSWin32 and defined $TOP_HDLR and $TOP_HDLR->{"_spawned"}) 0 140 140
Condition33%2/6
$_is_MSWin32 and defined $TOP_HDLR and $TOP_HDLR->{"_spawned"}
!ll&&!rl&&r
14000
$_is_MSWin32 and defined $TOP_HDLR
!ll&&!rl&&r
14000
MC/DC0%0/3
$_is_MSWin32 and defined $TOP_HDLR and $TOP_HDLR->{"_spawned"}
$_is_MSWin32 defined $TOP_HDLR $TOP_HDLR->{"_spawned"}
Truth table25%1/4
A and B and C
A= $_is_MSWin32B= defined $TOP_HDLRC= $TOP_HDLR->{"_spawned"}
ABCresult
0XX0
10X0
1100
1111
589 0 $TOP_HDLR->shutdown(1);
590 }
591 140 weaken($TOP_HDLR = $self);
592 }
593 elsif (refaddr($self) != refaddr($TOP_HDLR)) {
594 ## Reduce the maximum number of channels for nested sessions.
595 0 ▶ $self->{_data_channels} = 4 if ($self->{_data_channels} > 4);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_data_channels"} > 4 0 0 0
596 0 ▶ $self->{_lock_chn} = 1 if ($self->{_init_total_workers} > 4);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_init_total_workers"} > 4 0 0 0
597  
598 ## On Windows, instruct the manager process to enable win32 IPC.
599 0 ▶ if ($_is_MSWin32 && $ENV{'PERL_MCE_IPC'} ne 'win32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_MSWin32 and $ENV{"PERL_MCE_IPC"} ne "win32") 0 0 0
Condition0%0/3
$_is_MSWin32 and $ENV{"PERL_MCE_IPC"} ne "win32"
!ll&&!rl&&r
000
MC/DC0%0/2
$_is_MSWin32 and $ENV{"PERL_MCE_IPC"} ne "win32"
$_is_MSWin32 $ENV{"PERL_MCE_IPC"} ne "win32"
Truth table0%0/3
A and B
A= $_is_MSWin32B= $ENV{"PERL_MCE_IPC"} ne "win32"
ABresult
0X0
100
111
600 0 $ENV{'PERL_MCE_IPC'} = 'win32'; local $\ = undef;
601 0 my $_DAT_W_SOCK = $TOP_HDLR->{_dat_w_sock}->[0];
602 0 print {$_DAT_W_SOCK} OUTPUT_S_IPC.$LF . '0'.$LF;
603  
604 0 MCE::Util::_sock_ready($_DAT_W_SOCK, -1);
605 0 MCE::Util::_sysread($_DAT_W_SOCK, my($_buf), 1);
606 }
607 }
608  
609 ## -------------------------------------------------------------------------
610  
611 140 my $_data_channels = $self->{_data_channels};
612 140 my $_max_workers = _get_max_workers($self);
613 140 my $_use_threads = $self->{use_threads};
614  
615 ## Create [ 0 including 1 up to 8 ] locks for data channels (max 9).
616 140 $self->{'_mutex_0'} = MCE::Mutex->new( impl => 'Channel' );
617  
618 140 ▶ if ($self->{_lock_chn}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_lock_chn"}) 0 140 140
619 $self->{'_mutex_'.$_} = MCE::Mutex->new( impl => 'Channel' )
620 0 for (1 .. $_data_channels);
621 }
622  
623 ## Create two locks for use by MCE::Core::Input::{ Handle or Sequence }.
624 140 $self->{'_mutex_'.$_} = MCE::Mutex->new( impl => 'Channel' ) for (10 .. 11);
625  
626 ## Create sockets for IPC. sync, comm, input, data
627 140 MCE::Util::_sock_pair($self, qw(_bsb_r_sock _bsb_w_sock), undef, 1);
628 140 MCE::Util::_sock_pair($self, qw(_com_r_sock _com_w_sock), undef, 1);
629 140 MCE::Util::_sock_pair($self, qw(_que_r_sock _que_w_sock), undef, 1);
630 140 MCE::Util::_sock_pair($self, qw(_dat_r_sock _dat_w_sock), 0);
631  
632 MCE::Util::_sock_pair($self, qw(_dat_r_sock _dat_w_sock), $_, 1)
633 140 for (1 .. $_data_channels);
634  
635 140 ▶ if ($^O !~ /linux|android|aix/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($^O =~ /linux|android|aix/) 0 140 140
636 0 setsockopt($self->{_dat_r_sock}->[0], SOL_SOCKET, SO_RCVBUF, pack('i', 4096));
637 }
638  
639 140 ▶ if (defined $self->{init_relay}) { # relay
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"init_relay"}) 24 116 140
640 24 ▶ unless ($INC{'MCE/Relay.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($INC{"MCE/Relay.pm"}) 9 15 24
641 9 require MCE::Relay; MCE::Relay->import();
642 }
643 MCE::Util::_sock_pair($self, qw(_rla_r_sock _rla_w_sock), $_, 1)
644 24 for (0 .. $_max_workers - 1);
645 }
646  
647 140 $self->{_seed} = int(CORE::rand() * 1e9);
648  
649 ## -------------------------------------------------------------------------
650  
651 ## Spawn workers.
652 140 $self->{_pids} = [], $self->{_thrs} = [], $self->{_tids} = [];
653 140 $self->{_status} = [], $self->{_state} = [], $self->{_task} = [];
654  
655 140 ▶ if ($self->{loop_timeout} && !$_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"loop_timeout"} and not $_is_MSWin32) 0 140 140
Condition33%1/3
$self->{"loop_timeout"} and not $_is_MSWin32
!ll&&!rl&&r
14000
MC/DC0%0/2
$self->{"loop_timeout"} and not $_is_MSWin32
$self->{"loop_timeout"} not $_is_MSWin32
Truth table33%1/3
A and not(B)
A= $self->{"loop_timeout"}B= not $_is_MSWin32
ABresult
0X0
100
111
656 0 $self->{_pids_t} = {}, $self->{_pids_w} = {};
657 }
658  
659 140 ▶ local $SIG{TTIN}, local $SIG{TTOU}, local $SIG{WINCH} unless $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 140 0 140
660  
661 140 ▶ if (!defined $self->{user_tasks}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'user_tasks'}) { } 44 96 140
662 44 $self->{_total_workers} = $_max_workers;
663  
664 44 ▶ if (defined $_use_threads && $_use_threads == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_use_threads and $_use_threads == 1) { } 0 44 44
Condition33%1/3
defined $_use_threads and $_use_threads == 1
!ll&&!rl&&r
0440
MC/DC0%0/2
defined $_use_threads and $_use_threads == 1
defined $_use_threads $_use_threads == 1
Truth table33%1/3
A and B
A= defined $_use_threadsB= $_use_threads == 1
ABresult
0X0
100
111
665 0 _dispatch_thread($self, $_) for (1 .. $_max_workers);
666 } else {
667 44 _dispatch_child($self, $_) for (1 .. $_max_workers);
668 }
669  
670 21 $self->{_task}->[0] = { _total_workers => $_max_workers };
671  
672 21 for my $_i (1 .. $_max_workers) {
673 65 $self->{_state}->[$_i] = {
674 _task => undef, _task_id => undef, _task_wid => undef,
675 _params => undef, _chn => $_i % $_data_channels + 1
676 }
677 }
678 }
679 else {
680 96 my ($_task_id, $_wid);
681  
682 96 $self->{_total_workers} = 0;
683 96 $self->{_total_workers} += $_->{max_workers} for @{ $self->{user_tasks} };
684  
685 # Must spawn processes first for extra stability on BSD/Darwin.
686 96 $_task_id = $_wid = 0;
687  
688 96 for my $_task (@{ $self->{user_tasks} }) {
689 119 my $_tsk_use_threads = $_task->{use_threads};
690  
691 119 ▶ if (defined $_tsk_use_threads && $_tsk_use_threads == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_tsk_use_threads and $_tsk_use_threads == 1) { } 0 119 119
Condition33%1/3
defined $_tsk_use_threads and $_tsk_use_threads == 1
!ll&&!rl&&r
01190
MC/DC0%0/2
defined $_tsk_use_threads and $_tsk_use_threads == 1
defined $_tsk_use_threads $_tsk_use_threads == 1
Truth table33%1/3
A and B
A= defined $_tsk_use_threadsB= $_tsk_use_threads == 1
ABresult
0X0
100
111
692 0 $_wid += $_task->{max_workers};
693 } else {
694 _dispatch_child($self, ++$_wid, $_task, $_task_id, $_)
695 119 for (1 .. $_task->{max_workers});
696 }
697  
698 69 $_task_id++;
699 }
700  
701 # Then, spawn threads last.
702 46 $_task_id = $_wid = 0;
703  
704 46 for my $_task (@{ $self->{user_tasks} }) {
705 57 my $_tsk_use_threads = $_task->{use_threads};
706  
707 57 ▶ if (defined $_tsk_use_threads && $_tsk_use_threads == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_tsk_use_threads and $_tsk_use_threads == 1) { } 0 57 57
Condition33%1/3
defined $_tsk_use_threads and $_tsk_use_threads == 1
!ll&&!rl&&r
0570
MC/DC0%0/2
defined $_tsk_use_threads and $_tsk_use_threads == 1
defined $_tsk_use_threads $_tsk_use_threads == 1
Truth table33%1/3
A and B
A= defined $_tsk_use_threadsB= $_tsk_use_threads == 1
ABresult
0X0
100
111
708 _dispatch_thread($self, ++$_wid, $_task, $_task_id, $_)
709 0 for (1 .. $_task->{max_workers});
710 } else {
711 57 $_wid += $_task->{max_workers};
712 }
713  
714 57 $_task_id++;
715 }
716  
717 # Save state.
718 46 $_task_id = $_wid = 0;
719  
720 46 for my $_task (@{ $self->{user_tasks} }) {
721 $self->{_task}->[$_task_id] = {
722 _total_running => 0, _total_workers => $_task->{max_workers}
723 57 };
724 57 for my $_i (1 .. $_task->{max_workers}) {
725 105 $_wid += 1;
726 105 $self->{_state}->[$_wid] = {
727 _task => $_task, _task_id => $_task_id, _task_wid => $_i,
728 _params => undef, _chn => $_wid % $_data_channels + 1
729 }
730 }
731  
732 57 $_task_id++;
733 }
734 }
735  
736 ## -------------------------------------------------------------------------
737  
738 67 $self->{_send_cnt} = 0, $self->{_spawned} = 1;
739  
740 67 $SIG{__DIE__} = $_die_handler;
741 67 $SIG{__WARN__} = $_warn_handler;
742  
743 67 ▶ $MCE = $self if ($MCE->{_wid} == 0 && refaddr($MCE) != refaddr($self));
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self) 0 67 67
Condition33%1/3
$MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
!ll&&!rl&&r
0670
MC/DC0%0/2
$MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
$MCE::MCE->{"_wid"} == 0 builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
Truth table33%1/3
A and B
A= $MCE::MCE->{"_wid"} == 0B= builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
ABresult
0X0
100
111
744  
745 67 ▶ $MCE::_GMUTEX->unlock() if ($_tid && $MCE::_GMUTEX);
Branch: 1 branch
BranchTrueFalseTotal
if $_tid and $MCE::_GMUTEX 0 67 67
Condition33%1/3
$_tid and $MCE::_GMUTEX
!ll&&!rl&&r
6700
MC/DC0%0/2
$_tid and $MCE::_GMUTEX
$_tid $MCE::_GMUTEX
Truth table33%1/3
A and B
A= $_tidB= $MCE::_GMUTEX
ABresult
0X0
100
111
746  
747 67 return $self;
748 }
749  
750 ###############################################################################
751 ## ----------------------------------------------------------------------------
752 ## Process method, relay stubs, and AUTOLOAD for methods not used often.
753 ##
754 ###############################################################################
755  
756 106 ▶sub process {
Subroutine process: called CC=8 SCAR=22.2
Pod undocumented
757 106 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 106 106
758  
759 106 _validate_runstate($self, 'MCE::process');
760  
761 106 my ($_params_ref, $_input_data);
762  
763 106 ▶ if (ref $_[0] eq 'HASH' && ref $_[1] eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH' and ref $_[1] eq 'HASH') { } 6 100 106
elsif (ref $_[0] eq 'HASH') { } 95 5 100
Condition100%3/3
ref $_[0] eq "HASH" and ref $_[1] eq "HASH"
!ll&&!rl&&r
5956
MC/DC100%2/2
ref $_[0] eq "HASH" and ref $_[1] eq "HASH"
ref $_[0] eq "HASH" ref $_[1] eq "HASH"
Truth table100%3/3
A and B
A= ref $_[0] eq "HASH"B= ref $_[1] eq "HASH"
ABresult
0X0
100
111
764 6 $_params_ref = $_[0], $_input_data = $_[1];
765 } elsif (ref $_[0] eq 'HASH') {
766 95 $_params_ref = $_[0], $_input_data = $_[1];
767 } else {
768 5 $_params_ref = $_[1], $_input_data = $_[0];
769 }
770  
771 106 @_ = ();
772  
773 ## Set input data.
774 106 ▶ if (defined $_input_data) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_input_data) { } 106 0 106
elsif (not defined $_params_ref->{'input_data'} || defined $_params_ref->{'sequence'}) { } 0 0 0
775 106 $_params_ref->{input_data} = $_input_data;
776 }
777 ▶ elsif ( !defined $_params_ref->{input_data} &&
Condition0%0/3
defined $_params_ref->{'input_data'} || defined $_params_ref->{'sequence'}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $_params_ref->{'input_data'} || defined $_params_ref->{'sequence'}
defined $_params_ref->{'input_data'} defined $_params_ref->{'sequence'}
Truth table0%0/3
A || B
A= defined $_params_ref->{'input_data'}B= defined $_params_ref->{'sequence'}
ABresult
1X1
011
000
778 !defined $_params_ref->{sequence} ) {
779 0 _croak('MCE::process: (input_data or sequence) is not specified');
780 }
781  
782 ## Pass 0 to "not" auto-shutdown after processing.
783 106 $self->run(0, $_params_ref);
784  
785 79 return $self;
786 }
787  
788 0 ▶sub relay (;&) {
Subroutine relay: not called CC=2 SCAR=17.9
Pod undocumented
789 _croak('MCE::relay: (init_relay) is not defined')
790 0 ▶ unless (defined $MCE->{init_relay});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $MCE::MCE->{"init_relay"} 0 0 0
791 }
792  
793 {
794 94 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
795 94 *relay_unlock = \&relay;
796 }
797  
798 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=25 SCAR=64.8
799 # $AUTOLOAD = MCE::<method_name>
800  
801 0 my $_fcn = substr($MCE::AUTOLOAD, 5);
802 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
803  
804 # "for" sugar methods
805  
806 0 ▶ if ($_fcn eq 'forchunk') {
Branch: 3 branches
BranchTrueFalseTotal
if ($_fcn eq 'forchunk') { } 0 0 0
elsif ($_fcn eq 'foreach') { } 0 0 0
elsif ($_fcn eq 'forseq') { } 0 0 0
807 0 ▶ require MCE::Candy unless $INC{'MCE/Candy.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Candy.pm"} 0 0 0
808 0 return MCE::Candy::forchunk($self, @_);
809 }
810 elsif ($_fcn eq 'foreach') {
811 0 ▶ require MCE::Candy unless $INC{'MCE/Candy.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Candy.pm"} 0 0 0
812 0 return MCE::Candy::foreach($self, @_);
813 }
814 elsif ($_fcn eq 'forseq') {
815 0 ▶ require MCE::Candy unless $INC{'MCE/Candy.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"MCE/Candy.pm"} 0 0 0
816 0 return MCE::Candy::forseq($self, @_);
817 }
818  
819 # relay stubs for MCE::Relay
820  
821 0 ▶ if ($_fcn eq 'relay_lock' || $_fcn eq 'relay_recv') {
Branch: 2 branches
BranchTrueFalseTotal
if ($_fcn eq 'relay_lock' or $_fcn eq 'relay_recv') { } 0 0 0
elsif ($_fcn eq 'relay_final') { } 0 0 0
Condition0%0/3
$_fcn eq "relay_lock" or $_fcn eq "relay_recv"
l!l&&r!l&&!r
000
MC/DC0%0/2
$_fcn eq "relay_lock" or $_fcn eq "relay_recv"
$_fcn eq "relay_lock" $_fcn eq "relay_recv"
Truth table0%0/3
A or B
A= $_fcn eq "relay_lock"B= $_fcn eq "relay_recv"
ABresult
1X1
011
000
822 _croak('MCE::relay: (init_relay) is not defined')
823 0 ▶ unless (defined $MCE->{init_relay});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $MCE::MCE->{"init_relay"} 0 0 0
824 }
825 elsif ($_fcn eq 'relay_final') {
826 0 return;
827 }
828  
829 # worker immediately exits the chunking loop
830  
831 0 ▶ if ($_fcn eq 'last') {
Branch: 4 branches
BranchTrueFalseTotal
if ($_fcn eq 'last') { } 0 0 0
elsif ($_fcn eq 'next') { } 0 0 0
elsif ($_fcn eq 'pid') { } 0 0 0
elsif ($_fcn eq 'status') { } 0 0 0
832 _croak('MCE::last: method is not allowed by the manager process')
833 0 ▶ unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
834  
835 0 ▶ $self->{_last_jmp}() if (defined $self->{_last_jmp});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_last_jmp"} 0 0 0
836  
837 0 return;
838 }
839  
840 # worker starts the next iteration of the chunking loop
841  
842 elsif ($_fcn eq 'next') {
843 _croak('MCE::next: method is not allowed by the manager process')
844 0 ▶ unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
845  
846 0 ▶ $self->{_next_jmp}() if (defined $self->{_next_jmp});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_next_jmp"} 0 0 0
847  
848 0 return;
849 }
850  
851 # return the process ID, include thread ID for threads
852  
853 elsif ($_fcn eq 'pid') {
854 0 ▶ if (defined $self->{_pid}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'_pid'}) { } 0 0 0
elsif ($_has_threads and $self->{'use_threads'}) { } 0 0 0
855 0 return $self->{_pid};
856 ▶ } elsif ($_has_threads && $self->{use_threads}) {
Condition0%0/3
$_has_threads and $self->{"use_threads"}
!ll&&!rl&&r
000
MC/DC0%0/2
$_has_threads and $self->{"use_threads"}
$_has_threads $self->{"use_threads"}
Truth table0%0/3
A and B
A= $_has_threadsB= $self->{"use_threads"}
ABresult
0X0
100
111
857 0 return $$ .'.'. threads->tid();
858 }
859 0 return $$;
860 }
861  
862 # return the exit status
863 # _wrk_status holds the greatest exit status among workers exiting
864  
865 elsif ($_fcn eq 'status') {
866 _croak('MCE::status: method is not allowed by the worker process')
867 0 ▶ if ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
868  
869 0 ▶ return (defined $self->{_wrk_status}) ? $self->{_wrk_status} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'_wrk_status'} ? : 0 0 0
870 }
871  
872 0 _croak("Can't locate object method \"$_fcn\" via package \"MCE\"");
873 }
874  
875 ###############################################################################
876 ## ----------------------------------------------------------------------------
877 ## Restart worker method.
878 ##
879 ###############################################################################
880  
881 0 ▶sub restart_worker {
Subroutine restart_worker: not called CC=12 SCAR=50.5
Pod undocumented
882 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
883  
884 0 @_ = ();
885  
886 _croak('MCE::restart_worker: method is not allowed by the worker process')
887 0 ▶ if ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
888  
889 0 my $_wid = $self->{_exited_wid};
890  
891 0 my $_params = $self->{_state}->[$_wid]->{_params};
892 0 my $_task_wid = $self->{_state}->[$_wid]->{_task_wid};
893 0 my $_task_id = $self->{_state}->[$_wid]->{_task_id};
894 0 my $_task = $self->{_state}->[$_wid]->{_task};
895 0 my $_chn = $self->{_state}->[$_wid]->{_chn};
896  
897 0 $_params->{_chn} = $_chn;
898  
899 my $_use_threads = (defined $_task_id)
900 0 ▶ ? $_task->{use_threads} : $self->{use_threads};
Branch: 1 branch
BranchTrueFalseTotal
defined $_task_id ? : 0 0 0
901  
902 0 ▶ $self->{_task}->[$_task_id]->{_total_running} += 1 if (defined $_task_id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_task_id 0 0 0
903 0 ▶ $self->{_task}->[$_task_id]->{_total_workers} += 1 if (defined $_task_id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_task_id 0 0 0
904  
905 0 $self->{_total_running} += 1;
906 0 $self->{_total_workers} += 1;
907  
908 0 ▶ if (defined $_use_threads && $_use_threads == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_use_threads and $_use_threads == 1) { } 0 0 0
Condition0%0/3
defined $_use_threads and $_use_threads == 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_use_threads and $_use_threads == 1
defined $_use_threads $_use_threads == 1
Truth table0%0/3
A and B
A= defined $_use_threadsB= $_use_threads == 1
ABresult
0X0
100
111
909 0 _dispatch_thread($self, $_wid, $_task, $_task_id, $_task_wid, $_params);
910 } else {
911 0 _dispatch_child($self, $_wid, $_task, $_task_id, $_task_wid, $_params);
912 }
913  
914 0 delete $self->{_retry_cnt};
915  
916 0 ▶ if (defined $self->{spawn_delay} && $self->{spawn_delay} > 0.0) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'spawn_delay'} and $self->{'spawn_delay'} > 0.0) { } 0 0 0
elsif ($_tid or $_is_MSWin32) { } 0 0 0
Condition0%0/3
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
defined $self->{"spawn_delay"} $self->{"spawn_delay"} > 0
Truth table0%0/3
A and B
A= defined $self->{"spawn_delay"}B= $self->{"spawn_delay"} > 0
ABresult
0X0
100
111
917 0 sleep $self->{spawn_delay};
918 ▶ } elsif ($_tid || $_is_MSWin32) {
Condition0%0/3
$_tid or $_is_MSWin32
l!l&&r!l&&!r
000
MC/DC0%0/2
$_tid or $_is_MSWin32
$_tid $_is_MSWin32
Truth table0%0/3
A or B
A= $_tidB= $_is_MSWin32
ABresult
1X1
011
000
919 0 sleep 0.045;
920 }
921  
922 0 return;
923 }
924  
925 ###############################################################################
926 ## ----------------------------------------------------------------------------
927 ## Run method.
928 ##
929 ###############################################################################
930  
931 221 ▶sub run {
Subroutine run: called CC=85 SCAR=61.3
Pod undocumented
932 221 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 221 221
933  
934 _croak('MCE::run: method is not allowed by the worker process')
935 221 ▶ if ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 221 221
936  
937 221 my ($_auto_shutdown, $_params_ref);
938  
939 221 ▶ if (ref $_[0] eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 86 135 221
940 86 ▶ $_auto_shutdown = (defined $_[1]) ? $_[1] : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 86 0 86
941 86 $_params_ref = $_[0];
942 } else {
943 135 ▶ $_auto_shutdown = (defined $_[0]) ? $_[0] : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 106 29 135
944 135 $_params_ref = $_[1];
945 }
946  
947 221 @_ = ();
948  
949 221 ▶ my $_has_user_tasks = (defined $self->{user_tasks}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'user_tasks'} ? : 159 62 221
950 221 my $_requires_shutdown = 0;
951  
952 ## Unset params if workers have already been sent user_data via send.
953 ## Set user_func to NOOP if not specified.
954  
955 221 ▶ $_params_ref = undef if ($self->{_send_cnt});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_send_cnt"} 0 221 221
956  
957 221 ▶ if (!defined $self->{user_func} && !defined $_params_ref->{user_func}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"user_func"} or defined $_params_ref->{"user_func"}) 96 125 221
Condition66%2/3
defined $self->{"user_func"} or defined $_params_ref->{"user_func"}
l!l&&r!l&&!r
125096
MC/DC50%1/2
defined $self->{"user_func"} or defined $_params_ref->{"user_func"}
defined $self->{"user_func"} defined $_params_ref->{"user_func"}
Truth table66%2/3
A or B
A= defined $self->{"user_func"}B= defined $_params_ref->{"user_func"}
ABresult
1X1
011
000
958 96 $self->{user_func} = \&MCE::Signal::_NOOP;
959 }
960  
961 ## Set user specified params if specified.
962 ## Shutdown workers if determined by _sync_params or if processing a
963 ## scalar reference. Workers need to be restarted in order to pick up
964 ## on the new code or scalar reference.
965  
966 221 ▶ if (defined $_params_ref && ref $_params_ref eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_params_ref and ref $_params_ref eq "HASH") 192 29 221
Condition66%2/3
defined $_params_ref and ref $_params_ref eq "HASH"
!ll&&!rl&&r
290192
MC/DC50%1/2
defined $_params_ref and ref $_params_ref eq "HASH"
defined $_params_ref ref $_params_ref eq "HASH"
Truth table66%2/3
A and B
A= defined $_params_refB= ref $_params_ref eq "HASH"
ABresult
0X0
100
111
967 192 $_requires_shutdown = _sync_params($self, $_params_ref);
968 192 _validate_args($self);
969 }
970 221 ▶ if ($_has_user_tasks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks) 159 62 221
971 $self->{input_data} = $self->{user_tasks}->[0]->{input_data}
972 159 ▶ if ($self->{user_tasks}->[0]->{input_data});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"user_tasks"}[0]{"input_data"} 0 159 159
973 $self->{use_slurpio} = $self->{user_tasks}->[0]->{use_slurpio}
974 159 ▶ if ($self->{user_tasks}->[0]->{use_slurpio});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"user_tasks"}[0]{"use_slurpio"} 0 159 159
975 $self->{parallel_io} = $self->{user_tasks}->[0]->{parallel_io}
976 159 ▶ if ($self->{user_tasks}->[0]->{parallel_io});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"user_tasks"}[0]{"parallel_io"} 0 159 159
977 $self->{RS} = $self->{user_tasks}->[0]->{RS}
978 159 ▶ if ($self->{user_tasks}->[0]->{RS});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"user_tasks"}[0]{"RS"} 0 159 159
979 }
980 221 ▶ if (ref $self->{input_data} eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"input_data"} eq "SCALAR") 0 221 221
981 0 ▶ if (refaddr($self->{input_data}) != $self->{_last_sref}) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::refaddr($self->{"input_data"}) != $self->{"_last_sref"}) 0 0 0
982 0 $_requires_shutdown = 1;
983 }
984 0 $self->{_last_sref} = refaddr($self->{input_data});
985 }
986  
987 221 ▶ $self->shutdown() if ($_requires_shutdown);
Branch: 1 branch
BranchTrueFalseTotal
if $_requires_shutdown 0 221 221
988  
989 ## -------------------------------------------------------------------------
990  
991 221 $self->{_wrk_status} = 0;
992  
993 ## Spawn workers.
994 221 ▶ $self->spawn() unless ($self->{_spawned});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_spawned"} 140 81 221
995 148 ▶ return $self unless ($self->{_total_workers});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_total_workers"} 0 148 148
996  
997 148 local $SIG{__DIE__} = \&MCE::Signal::_die_handler;
998 148 local $SIG{__WARN__} = \&MCE::Signal::_warn_handler;
999  
1000 148 ▶ $MCE = $self if ($MCE->{_wid} == 0 && refaddr($MCE) != refaddr($self));
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self) 0 148 148
Condition33%1/3
$MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
!ll&&!rl&&r
01480
MC/DC0%0/2
$MCE::MCE->{"_wid"} == 0 and builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
$MCE::MCE->{"_wid"} == 0 builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
Truth table33%1/3
A and B
A= $MCE::MCE->{"_wid"} == 0B= builtin::refaddr($MCE::MCE) != builtin::refaddr($self)
ABresult
0X0
100
111
1001  
1002 148 my ($_input_data, $_input_file, $_input_glob, $_seq);
1003 148 my ($_abort_msg, $_first_msg, $_run_mode, $_single_dim);
1004 148 my $_chunk_size = $self->{chunk_size};
1005  
1006 $_seq = ($_has_user_tasks && $self->{user_tasks}->[0]->{sequence})
1007 ? $self->{user_tasks}->[0]->{sequence}
1008 148 ▶ : $self->{sequence};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks && $self->{'user_tasks'}[0]{'sequence'} ? : 0 148 148
Condition66%2/3
$_has_user_tasks and $self->{"user_tasks"}[0]{"sequence"}
!ll&&!rl&&r
391090
MC/DC0%0/2
$_has_user_tasks and $self->{"user_tasks"}[0]{"sequence"}
$_has_user_tasks $self->{"user_tasks"}[0]{"sequence"}
Truth table66%2/3
A and B
A= $_has_user_tasksB= $self->{"user_tasks"}[0]{"sequence"}
ABresult
0X0
100
111
1009  
1010 ## Determine run mode for workers.
1011 148 ▶ if (defined $_seq) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_seq) { } 18 130 148
elsif (defined $self->{'input_data'}) { } 84 46 130
1012 my ($_begin, $_end, $_step) = (ref $_seq eq 'ARRAY')
1013 18 ▶ ? @{ $_seq } : ($_seq->{begin}, $_seq->{end}, $_seq->{step});
Branch: 1 branch
BranchTrueFalseTotal
ref $_seq eq 'ARRAY' ? : 18 0 18
1014  
1015 $_chunk_size = $self->{user_tasks}->[0]->{chunk_size}
1016 18 ▶ if ($_has_user_tasks && $self->{user_tasks}->[0]->{chunk_size});
Branch: 1 branch
BranchTrueFalseTotal
if $_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"} 0 18 18
Condition66%2/3
$_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"}
!ll&&!rl&&r
4140
MC/DC0%0/2
$_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"}
$_has_user_tasks $self->{"user_tasks"}[0]{"chunk_size"}
Truth table66%2/3
A and B
A= $_has_user_tasksB= $self->{"user_tasks"}[0]{"chunk_size"}
ABresult
0X0
100
111
1017  
1018 18 $_run_mode = 'sequence';
1019 18 $_abort_msg = int(($_end - $_begin) / $_step / $_chunk_size); # + 1;
1020  
1021 # Previously + 1 above. Below, support for large numbers, 1e16 and beyond.
1022 # E.g. sequence => [ 1, 1e16 ], chunk_size => 1e11
1023 #
1024 # Perl: int((1e15 - 1) / 1 / 1e11) = 9999
1025 # Perl: int((1e16 - 1) / 1 / 1e11) = 100000 wrong, due to precision limit
1026 # Calc: int((1e16 - 1) / 1 / 1e11) = 99999
1027  
1028 18 ▶ if ( $_step > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_step > 0) { } 18 0 18
1029 18 ▶ $_abort_msg++
Branch: 1 branch
BranchTrueFalseTotal
if $_abort_msg * $_chunk_size * abs($_step) + $_begin <= $_end 18 0 18
1030 if ($_abort_msg * $_chunk_size * abs($_step) + $_begin <= $_end);
1031 } else {
1032 0 ▶ $_abort_msg++
Branch: 1 branch
BranchTrueFalseTotal
if $_abort_msg * $_chunk_size * abs($_step) + $_end <= $_begin 0 0 0
1033 if ($_abort_msg * $_chunk_size * abs($_step) + $_end <= $_begin);
1034 }
1035  
1036 18 $_first_msg = 0;
1037 }
1038 elsif (defined $self->{input_data}) {
1039 84 my $_ref = ref $self->{input_data};
1040  
1041 84 ▶ if ($_ref eq '') { # File mode
Branch: 6 branches
BranchTrueFalseTotal
if ($_ref eq '') { } 18 66 84
elsif ($_ref eq 'ARRAY') { } 45 21 66
elsif ($_ref eq 'HASH') { } 3 18 21
elsif ($_ref =~ /^(?:GLOB|FileHandle|IO::)/) { } 18 0 18
elsif ($_ref =~ /^(?:CODE|Iterator::)/) { } 0 0 0
elsif ($_ref eq 'SCALAR') { } 0 0 0
1042 18 $_run_mode = 'file';
1043 18 $_input_file = $self->{input_data};
1044 18 $_input_data = $_input_glob = undef;
1045 18 $_abort_msg = (-s $_input_file) + 1;
1046 18 $_first_msg = 0; ## Begin at offset position
1047  
1048 18 ▶ if ((-s $_input_file) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (-s $_input_file == 0) 0 18 18
1049 0 ▶ $self->shutdown() if ($_auto_shutdown == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $_auto_shutdown == 1 0 0 0
1050 0 return $self;
1051 }
1052 }
1053 elsif ($_ref eq 'ARRAY') { # Array mode
1054 45 $_run_mode = 'array';
1055 45 $_input_data = $self->{input_data};
1056 45 $_input_file = $_input_glob = undef;
1057 45 ▶ $_single_dim = 1 if (ref $_input_data->[0] eq '');
Branch: 1 branch
BranchTrueFalseTotal
if ref $_input_data->[0] eq "" 45 0 45
1058 45 $_abort_msg = 0; ## Flag: Has Data: No
1059 45 $_first_msg = 1; ## Flag: Has Data: Yes
1060  
1061 45 ▶ if (@{ $_input_data } == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$_input_data;} == 0) 0 45 45
1062 0 ▶ $self->shutdown() if ($_auto_shutdown == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $_auto_shutdown == 1 0 0 0
1063 0 return $self;
1064 }
1065 }
1066 elsif ($_ref eq 'HASH') { # Hash mode
1067 3 $_run_mode = 'hash';
1068 3 $_input_data = $self->{input_data};
1069 3 $_input_file = $_input_glob = undef;
1070 3 $_abort_msg = 0; ## Flag: Has Data: No
1071 3 $_first_msg = 1; ## Flag: Has Data: Yes
1072  
1073 3 ▶ if (scalar( keys %{ $_input_data } ) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %{$_input_data;} == 0) 0 3 3
1074 0 ▶ $self->shutdown() if ($_auto_shutdown == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $_auto_shutdown == 1 0 0 0
1075 0 return $self;
1076 }
1077 }
1078 elsif ($_ref =~ /^(?:GLOB|FileHandle|IO::)/) { # Glob mode
1079 18 $_run_mode = 'glob';
1080 18 $_input_glob = $self->{input_data};
1081 18 $_input_data = $_input_file = undef;
1082 18 $_abort_msg = 0; ## Flag: Has Data: No
1083 18 $_first_msg = 1; ## Flag: Has Data: Yes
1084 }
1085 elsif ($_ref =~ /^(?:CODE|Iterator::)/) { # Iterator mode
1086 0 $_run_mode = 'iterator';
1087 0 $_input_data = $self->{input_data};
1088 0 $_input_file = $_input_glob = undef;
1089 0 $_abort_msg = 0; ## Flag: Has Data: No
1090 0 $_first_msg = 1; ## Flag: Has Data: Yes
1091 }
1092 elsif ($_ref eq 'SCALAR') { # Memory mode
1093 0 $_run_mode = 'memory';
1094 0 $_input_data = $_input_file = $_input_glob = undef;
1095 0 $_abort_msg = length(${ $self->{input_data} }) + 1;
1096 0 $_first_msg = 0; ## Begin at offset position
1097  
1098 0 ▶ if (length(${ $self->{input_data} }) == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (length ${$self->{"input_data"};} == 0) 0 0 0
1099 0 ▶ return $self->shutdown() if ($_auto_shutdown == 1);
Branch: 1 branch
BranchTrueFalseTotal
if $_auto_shutdown == 1 0 0 0
1100 }
1101 }
1102 else {
1103 0 _croak('MCE::run: (input_data) is not valid');
1104 }
1105 }
1106 else { # Nodata mode
1107 46 $_abort_msg = undef, $_run_mode = 'nodata';
1108 }
1109  
1110 ## -------------------------------------------------------------------------
1111  
1112 148 my $_total_workers = $self->{_total_workers};
1113 148 my $_send_cnt = $self->{_send_cnt};
1114  
1115 148 ▶ if ($_send_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_send_cnt) { } 0 148 148
1116 0 $self->{_total_running} = $_send_cnt;
1117 0 $self->{_task}->[0]->{_total_running} = $_send_cnt;
1118 }
1119 else {
1120 148 $self->{_total_running} = $_total_workers;
1121  
1122 148 my ($_frozen_nodata, $_wid, %_params_nodata, %_task0_wids);
1123 148 my $_COM_R_SOCK = $self->{_com_r_sock};
1124 148 my $_submit_delay = $self->{submit_delay};
1125  
1126 my %_params = (
1127 '_abort_msg' => $_abort_msg, '_chunk_size' => $_chunk_size,
1128 '_input_file' => $_input_file, '_run_mode' => $_run_mode,
1129 '_bounds_only' => $self->{bounds_only},
1130 '_max_retries' => $self->{max_retries},
1131 '_parallel_io' => $self->{parallel_io},
1132 '_progress' => $self->{progress} ? 1 : 0,
1133 '_sequence' => $self->{sequence},
1134 '_user_args' => $self->{user_args},
1135 '_use_slurpio' => $self->{use_slurpio},
1136 '_RS' => $self->{RS}
1137 148 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'progress'} ? : 0 148 148
1138  
1139 148 my $_frozen_params = $self->{freeze}(\%_params);
1140 148 $_frozen_params = length($_frozen_params).$LF . $_frozen_params;
1141  
1142 148 ▶ if ($_has_user_tasks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks) 109 39 148
1143 109 %_params_nodata = ( %_params,
1144 '_abort_msg' => undef, '_run_mode' => 'nodata'
1145 );
1146 109 $_frozen_nodata = $self->{freeze}(\%_params_nodata);
1147 109 $_frozen_nodata = length($_frozen_nodata).$LF . $_frozen_nodata;
1148  
1149 109 for my $_t (@{ $self->{_task} }) {
1150 181 $_t->{_total_running} = $_t->{_total_workers};
1151 }
1152 109 for my $_i (1 .. @{ $self->{_state} } - 1) {
1153 351 ▶ $_task0_wids{$_i} = undef unless ($self->{_state}[$_i]{_task_id});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_state"}[$_i]{"_task_id"} 205 146 351
1154 }
1155 }
1156  
1157 148 local $\ = undef; local $/ = $LF;
1158  
1159 ## Insert the first message into the queue if defined.
1160 148 ▶ if (defined $_first_msg) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_first_msg) 102 46 148
1161 102 syswrite($self->{_que_w_sock}, pack($_que_template, 0, $_first_msg));
1162 }
1163  
1164 ## Submit params data to workers.
1165 148 for my $_i (1 .. $_total_workers) {
1166 452 print({$_COM_R_SOCK} $_i.$LF), chomp($_wid = <$_COM_R_SOCK>);
1167  
1168 452 ▶ if (!$_has_user_tasks || exists $_task0_wids{$_wid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_has_user_tasks or exists $_task0_wids{$_wid}) { } 306 146 452
Condition100%3/3
not $_has_user_tasks or exists $_task0_wids{$_wid}
l!l&&r!l&&!r
101205146
MC/DC100%2/2
not $_has_user_tasks or exists $_task0_wids{$_wid}
not $_has_user_tasks exists $_task0_wids{$_wid}
Truth table100%3/3
not(A) or B
A= not $_has_user_tasksB= exists $_task0_wids{$_wid}
ABresult
1X1
011
000
1169 306 print({$_COM_R_SOCK} $_frozen_params), <$_COM_R_SOCK>;
1170 306 $self->{_state}[$_wid]{_params} = \%_params;
1171 } else {
1172 146 print({$_COM_R_SOCK} $_frozen_nodata), <$_COM_R_SOCK>;
1173 146 $self->{_state}[$_wid]{_params} = \%_params_nodata;
1174 }
1175  
1176 452 ▶ sleep $_submit_delay
Branch: 1 branch
BranchTrueFalseTotal
if defined $_submit_delay and $_submit_delay > 0 0 452 452
Condition33%1/3
defined $_submit_delay and $_submit_delay > 0
!ll&&!rl&&r
45200
MC/DC0%0/2
defined $_submit_delay and $_submit_delay > 0
defined $_submit_delay $_submit_delay > 0
Truth table33%1/3
A and B
A= defined $_submit_delayB= $_submit_delay > 0
ABresult
0X0
100
111
1177 if defined($_submit_delay) && $_submit_delay > 0.0;
1178 }
1179 }
1180  
1181 ## -------------------------------------------------------------------------
1182  
1183 148 $self->{_total_exited} = 0;
1184  
1185 ## Call the output function.
1186 148 ▶ if ($self->{_total_running} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_total_running"} > 0) 148 0 148
1187 148 $self->{_mgr_live} = 1;
1188 148 $self->{_abort_msg} = $_abort_msg;
1189 148 $self->{_single_dim} = $_single_dim;
1190  
1191 148 ▶ lock $self->{_run_lock} if $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 0 148 148
1192  
1193 148 ▶ if (!$_send_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_send_cnt) 148 0 148
1194 ## Notify workers to commence processing.
1195 148 ▶ if ($_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_MSWin32) { } 0 148 148
1196 0 my $_buf = _sprintf("%${_total_workers}s", "");
1197 0 syswrite($self->{_bsb_r_sock}, $_buf);
1198 } else {
1199 148 my $_BSB_R_SOCK = $self->{_bsb_r_sock};
1200 148 for my $_i (1 .. $_total_workers) {
1201 452 syswrite($_BSB_R_SOCK, $LF);
1202 }
1203 }
1204 }
1205  
1206 148 _output_loop( $self, $_input_data, $_input_glob,
1207 \%_plugin_function, \@_plugin_loop_begin, \@_plugin_loop_end
1208 );
1209  
1210 148 $self->{_mgr_live} = $self->{_abort_msg} = $self->{_single_dim} = undef;
1211 }
1212  
1213 ## Remove the last message from the queue.
1214 148 ▶ if (!$_send_cnt && $_run_mode ne 'nodata') {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_send_cnt and $_run_mode ne "nodata") 102 46 148
Condition66%2/3
not $_send_cnt and $_run_mode ne "nodata"
!ll&&!rl&&r
046102
MC/DC50%1/2
not $_send_cnt and $_run_mode ne "nodata"
not $_send_cnt $_run_mode ne "nodata"
Truth table66%2/3
not(A) and B
A= not $_send_cntB= $_run_mode ne "nodata"
ABresult
0X0
100
111
1215 MCE::Util::_sysread($self->{_que_r_sock}, my($_buf), $_que_read_size)
1216 102 ▶ if ( defined $self->{_que_r_sock} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_que_r_sock"} 102 0 102
1217 }
1218  
1219 148 $self->{_send_cnt} = 0;
1220  
1221 ## Shutdown workers.
1222 148 ▶ if ($_auto_shutdown || $self->{_total_exited}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_auto_shutdown or $self->{'_total_exited'}) { } 15 133 148
elsif ($INC{'MCE/Simple.pm'}) { } 0 133 133
elsif ($^S or $ENV{'PERL_IPERL_RUNNING'}) { } 0 133 133
Condition66%2/3
$_auto_shutdown or $self->{"_total_exited"}
l!l&&r!l&&!r
150133
MC/DC50%1/2
$_auto_shutdown or $self->{"_total_exited"}
$_auto_shutdown $self->{"_total_exited"}
Truth table66%2/3
A or B
A= $_auto_shutdownB= $self->{"_total_exited"}
ABresult
1X1
011
000
1223 15 $self->shutdown();
1224 }
1225 elsif ($INC{'MCE/Simple.pm'}) {
1226 0 $self->shutdown();
1227 }
1228 ▶ elsif ($^S || $ENV{'PERL_IPERL_RUNNING'}) {
Condition33%1/3
$^S or $ENV{"PERL_IPERL_RUNNING"}
l!l&&r!l&&!r
00133
MC/DC0%0/2
$^S or $ENV{"PERL_IPERL_RUNNING"}
$^S $ENV{"PERL_IPERL_RUNNING"}
Truth table33%1/3
A or B
A= $^SB= $ENV{"PERL_IPERL_RUNNING"}
ABresult
1X1
011
000
1229 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
unless ($INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"}) 0 0 0
Condition0%0/15
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"}
l!l&&r!l&&!r
000
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Tk.pm"}
l!l&&r!l&&!r
000
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"} or $INC{"Gearman/Util.pm"}
l!l&&r!l&&!r
000
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"}
l!l&&r!l&&!r
000
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"}
l!l&&r!l&&!r
000
MC/DC0%0/6
$INC{"Mojo/IOLoop.pm"} or $INC{"Win32/GUI.pm"} or $INC{"Gearman/XS.pm"} or $INC{"Gearman/Util.pm"} or $INC{"Tk.pm"} or $INC{"Wx.pm"}
$INC{"Mojo/IOLoop.pm"} $INC{"Win32/GUI.pm"} $INC{"Gearman/XS.pm"} $INC{"Gearman/Util.pm"} $INC{"Tk.pm"} $INC{"Wx.pm"}
Truth table0%0/7
A or B or C or D or E or F
A= $INC{"Mojo/IOLoop.pm"}B= $INC{"Win32/GUI.pm"}C= $INC{"Gearman/XS.pm"}D= $INC{"Gearman/Util.pm"}E= $INC{"Tk.pm"}F= $INC{"Wx.pm"}
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
1230 !$INC{'Mojo/IOLoop.pm'} && !$INC{'Win32/GUI.pm'} &&
1231 !$INC{'Gearman/XS.pm'} && !$INC{'Gearman/Util.pm'} &&
1232 !$INC{'Tk.pm'} && !$INC{'Wx.pm'}
1233 ) {
1234 # running inside eval or IPerl, check stack trace
1235 0 my $_t = Carp::longmess(); $_t =~ s/\teval [^\n]+\n$//;
1236  
1237 0 ▶ if ( $_t =~ /^(?:[^\n]+\n){1,7}\teval / ||
Branch: 1 branch
BranchTrueFalseTotal
if ($_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ or $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/ or $_tid and not $self->{"use_threads"}) 0 0 0
Condition0%0/12
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ or $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/ or $_tid and not $self->{"use_threads"}
l!l&&r!l&&!r
000
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ or $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/
l!l&&r!l&&!r
000
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/
l!l&&r!l&&!r
000
$_tid and not $self->{"use_threads"}
!ll&&!rl&&r
000
MC/DC0%0/5
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ or $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/ or $_tid and not $self->{"use_threads"}
$_t =~ /^(?:[^\n]+\n){1,7}\teval / $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/ $_tid not $self->{"use_threads"}
Truth table0%0/6
A or B or C or D and not(E)
A= $_t =~ /^(?:[^\n]+\n){1,7}\teval /B= $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/C= $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/D= $_tidE= not $self->{"use_threads"}
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
1238 $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ ||
1239 $_t =~ /\n\tMCE::_dispatch\(\) [^\n]+ thread \d+\n$/ ||
1240 ( $_tid && !$self->{use_threads} ) )
1241 {
1242 0 $self->shutdown();
1243 }
1244 }
1245 }
1246  
1247 148 return $self;
1248 }
1249  
1250 ###############################################################################
1251 ## ----------------------------------------------------------------------------
1252 ## Send method.
1253 ##
1254 ###############################################################################
1255  
1256 0 ▶sub send {
Subroutine send: not called CC=15 SCAR=54.8
Pod undocumented
1257 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1258  
1259 _croak('MCE::send: method is not allowed by the worker process')
1260 0 ▶ if ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
1261 _croak('MCE::send: method is not allowed while running')
1262 0 ▶ if ($self->{_total_running});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_total_running"} 0 0 0
1263  
1264 _croak('MCE::send: method cannot be used with input_data or sequence')
1265 0 ▶ if (defined $self->{input_data} || defined $self->{sequence});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"input_data"} or defined $self->{"sequence"} 0 0 0
Condition0%0/3
defined $self->{"input_data"} or defined $self->{"sequence"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $self->{"input_data"} or defined $self->{"sequence"}
defined $self->{"input_data"} defined $self->{"sequence"}
Truth table0%0/3
A or B
A= defined $self->{"input_data"}B= defined $self->{"sequence"}
ABresult
1X1
011
000
1266 _croak('MCE::send: method cannot be used with user_tasks')
1267 0 ▶ if (defined $self->{user_tasks});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"user_tasks"} 0 0 0
1268  
1269 0 my $_data_ref;
1270  
1271 0 ▶ if (ref $_[0] eq 'ARRAY' || ref $_[0] eq 'HASH' || ref $_[0] eq 'PDL') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY' or ref $_[0] eq 'HASH' or ref $_[0] eq 'PDL') { } 0 0 0
Condition0%0/6
ref $_[0] eq "ARRAY" or ref $_[0] eq "HASH" or ref $_[0] eq "PDL"
l!l&&r!l&&!r
000
ref $_[0] eq "ARRAY" or ref $_[0] eq "HASH"
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_[0] eq "ARRAY" or ref $_[0] eq "HASH" or ref $_[0] eq "PDL"
ref $_[0] eq "ARRAY" ref $_[0] eq "HASH" ref $_[0] eq "PDL"
Truth table0%0/4
A or B or C
A= ref $_[0] eq "ARRAY"B= ref $_[0] eq "HASH"C= ref $_[0] eq "PDL"
ABCresult
1XX1
01X1
0011
0000
1272 0 $_data_ref = $_[0];
1273 } else {
1274 0 _croak('MCE::send: ARRAY, HASH, or a PDL reference is not specified');
1275 }
1276  
1277 0 @_ = ();
1278  
1279 0 ▶ $self->{_send_cnt} = 0 unless (defined $self->{_send_cnt});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_send_cnt"} 0 0 0
1280  
1281 ## -------------------------------------------------------------------------
1282  
1283 ## Spawn workers.
1284 0 ▶ $self->spawn() unless ($self->{_spawned});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_spawned"} 0 0 0
1285  
1286 _croak('MCE::send: Sending greater than # of workers is not allowed')
1287 0 ▶ if ($self->{_send_cnt} >= $self->{_task}->[0]->{_total_workers});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_send_cnt"} >= $self->{"_task"}[0]{"_total_workers"} 0 0 0
1288  
1289 0 local $SIG{__DIE__} = \&MCE::Signal::_die_handler;
1290 0 local $SIG{__WARN__} = \&MCE::Signal::_warn_handler;
1291  
1292 ## Begin data submission.
1293 0 local $\ = undef; local $/ = $LF;
1294  
1295 0 my $_COM_R_SOCK = $self->{_com_r_sock};
1296 0 my $_submit_delay = $self->{submit_delay};
1297 0 my $_frozen_data = $self->{freeze}($_data_ref);
1298 0 my $_len = length $_frozen_data;
1299  
1300 ## Submit data to worker.
1301 0 print({$_COM_R_SOCK} '_data'.$LF), <$_COM_R_SOCK>;
1302 0 print({$_COM_R_SOCK} $_len.$LF, $_frozen_data), <$_COM_R_SOCK>;
1303  
1304 0 $self->{_send_cnt} += 1;
1305  
1306 0 ▶ sleep $_submit_delay
Branch: 1 branch
BranchTrueFalseTotal
if defined $_submit_delay and $_submit_delay > 0 0 0 0
Condition0%0/3
defined $_submit_delay and $_submit_delay > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_submit_delay and $_submit_delay > 0
defined $_submit_delay $_submit_delay > 0
Truth table0%0/3
A and B
A= defined $_submit_delayB= $_submit_delay > 0
ABresult
0X0
100
111
1307 if defined($_submit_delay) && $_submit_delay > 0.0;
1308  
1309 0 return $self;
1310 }
1311  
1312 ###############################################################################
1313 ## ----------------------------------------------------------------------------
1314 ## Shutdown method.
1315 ##
1316 ###############################################################################
1317  
1318 67 ▶sub shutdown {
Subroutine shutdown: called CC=25 SCAR=38.3
Pod undocumented
1319 67 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 67 67
1320 67 ▶ my $_no_lock = shift || 0;
Condition50%1/2
shift() || 0
l!l
067
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
1321  
1322 67 @_ = ();
1323  
1324 ## Return unless spawned or already shutdown.
1325 67 ▶ return unless $self->{_spawned};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_spawned"} 0 67 67
1326  
1327 ## Return if signaled.
1328 67 ▶ if ($MCE::Signal::KILLED) {
Branch: 1 branch
BranchTrueFalseTotal
if ($MCE::Signal::KILLED) 0 67 67
1329 0 ▶ if (defined $self->{_sess_dir}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_sess_dir"}) 0 0 0
1330 0 my $_sess_dir = delete $self->{_sess_dir};
1331 0 ▶ rmdir $_sess_dir if -d $_sess_dir;
Branch: 1 branch
BranchTrueFalseTotal
if -d $_sess_dir 0 0 0
1332 }
1333 0 return;
1334 }
1335  
1336 67 _validate_runstate($self, 'MCE::shutdown');
1337  
1338 ## Complete processing before shutting down.
1339 67 ▶ $self->run(0) if ($self->{_send_cnt});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_send_cnt"} 0 67 67
1340  
1341 67 local $SIG{__DIE__} = \&MCE::Signal::_die_handler;
1342 67 local $SIG{__WARN__} = \&MCE::Signal::_warn_handler;
1343  
1344 67 my $_COM_R_SOCK = $self->{_com_r_sock};
1345 67 my $_data_channels = $self->{_data_channels};
1346 67 my $_total_workers = $self->{_total_workers};
1347 67 my $_sess_dir = $self->{_sess_dir};
1348  
1349 67 ▶ if (defined $TOP_HDLR && refaddr($self) == refaddr($TOP_HDLR)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $TOP_HDLR and builtin::refaddr($self) == builtin::refaddr($TOP_HDLR)) 67 0 67
Condition33%1/3
defined $TOP_HDLR and builtin::refaddr($self) == builtin::refaddr($TOP_HDLR)
!ll&&!rl&&r
0067
MC/DC0%0/2
defined $TOP_HDLR and builtin::refaddr($self) == builtin::refaddr($TOP_HDLR)
defined $TOP_HDLR builtin::refaddr($self) == builtin::refaddr($TOP_HDLR)
Truth table33%1/3
A and B
A= defined $TOP_HDLRB= builtin::refaddr($self) == builtin::refaddr($TOP_HDLR)
ABresult
0X0
100
111
1350 67 $TOP_HDLR = undef;
1351 }
1352  
1353 ## -------------------------------------------------------------------------
1354  
1355 67 ▶ lock $_MCE_LOCK if ($_has_threads && $_is_winenv && !$_no_lock);
Branch: 1 branch
BranchTrueFalseTotal
if $_has_threads and $_is_winenv and not $_no_lock 0 67 67
Condition33%2/6
$_has_threads and $_is_winenv and not $_no_lock
!ll&&!rl&&r
6700
$_has_threads and $_is_winenv
!ll&&!rl&&r
6700
MC/DC0%0/3
$_has_threads and $_is_winenv and not $_no_lock
$_has_threads $_is_winenv not $_no_lock
Truth table25%1/4
A and B and not(C)
A= $_has_threadsB= $_is_winenvC= not $_no_lock
ABCresult
0XX0
10X0
1100
1111
1356  
1357 ## Notify workers to exit loop.
1358 67 local ($!, $?, $_); local $\ = undef; local $/ = $LF;
1359  
1360 67 for (1 .. $_total_workers) {
1361 170 print({$_COM_R_SOCK} '_exit'.$LF), <$_COM_R_SOCK>;
1362 }
1363  
1364 ## Reap children and/or threads.
1365 67 ▶ if (@{ $self->{_pids} } > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"_pids"};} > 0) 67 0 67
1366 67 my $_list = $self->{_pids};
1367 67 for my $i (0 .. @{ $_list }) {
1368 237 ▶ waitpid($_list->[$i], 0) if $_list->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $_list->[$i] 170 67 237
1369 }
1370 }
1371 67 ▶ if (@{ $self->{_thrs} } > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"_thrs"};} > 0) 0 67 67
1372 0 my $_list = $self->{_thrs};
1373 0 for my $i (0 .. @{ $_list }) {
1374 0 ▶ $_list->[$i]->join() if $_list->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $_list->[$i] 0 0 0
1375 }
1376 }
1377  
1378 ## Close sockets.
1379 67 $_COM_R_SOCK = undef;
1380  
1381 67 MCE::Util::_destroy_socks($self, qw(
1382 _bsb_w_sock _bsb_r_sock _com_w_sock _com_r_sock _que_w_sock _que_r_sock
1383 _dat_w_sock _dat_r_sock _rla_w_sock _rla_r_sock
1384 ));
1385  
1386 ## -------------------------------------------------------------------------
1387  
1388 ## Destroy mutexes.
1389 67 for my $_i (0 .. $_data_channels) { delete $self->{'_mutex_'.$_i}; }
1390 67 for my $_j (10 .. 11) { delete $self->{'_mutex_'.$_j}; } # input mutexes
1391  
1392 ## Remove session directory.
1393 67 ▶ rmdir $_sess_dir if (defined $_sess_dir && -d $_sess_dir);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_sess_dir and -d $_sess_dir 0 67 67
Condition33%1/3
defined $_sess_dir and -d $_sess_dir
!ll&&!rl&&r
6700
MC/DC0%0/2
defined $_sess_dir and -d $_sess_dir
defined $_sess_dir -d $_sess_dir
Truth table33%1/3
A and B
A= defined $_sess_dirB= -d $_sess_dir
ABresult
0X0
100
111
1394  
1395 ## Reset instance.
1396 67 undef @{$self->{_pids}}; undef @{$self->{_thrs}}; undef @{$self->{_tids}};
1397 67 undef @{$self->{_state}}; undef @{$self->{_status}}; undef @{$self->{_task}};
1398  
1399 67 $self->{_chunk_id} = $self->{_send_cnt} = $self->{_spawned} = 0;
1400 67 $self->{_total_running} = $self->{_total_exited} = 0;
1401 67 $self->{_total_workers} = 0;
1402 67 $self->{_sess_dir} = undef;
1403  
1404 67 ▶ if ($self->{loop_timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"loop_timeout"}) 0 67 67
1405 0 delete $self->{_pids_t};
1406 0 delete $self->{_pids_w};
1407 }
1408  
1409 67 return;
1410 }
1411  
1412 ###############################################################################
1413 ## ----------------------------------------------------------------------------
1414 ## Barrier sync and yield methods.
1415 ##
1416 ###############################################################################
1417  
1418 0 ▶sub sync {
Subroutine sync: not called CC=7 SCAR=40.3
Pod undocumented
1419 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1420  
1421 0 ▶ return unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
1422  
1423 ## Barrier synchronization is supported for task 0 at this time.
1424 ## Note: Workers are assigned task_id 0 when omitting user_tasks.
1425  
1426 0 ▶ return if ($self->{_task_id} > 0);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_task_id"} > 0 0 0 0
1427  
1428 0 my $_chn = $self->{_chn};
1429 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1430 0 my $_BSB_R_SOCK = $self->{_bsb_r_sock};
1431 0 my $_BSB_W_SOCK = $self->{_bsb_w_sock};
1432 0 my $_buf;
1433  
1434 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1435  
1436 ## Notify the manager process (barrier begin).
1437 0 print {$_DAT_W_SOCK} OUTPUT_B_SYN.$LF . $_chn.$LF;
1438  
1439 ## Wait until all workers from (task_id 0) have synced.
1440 0 ▶ MCE::Util::_sock_ready($_BSB_R_SOCK, -1) if $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 0 0 0
1441 0 MCE::Util::_sysread($_BSB_R_SOCK, $_buf, 1);
1442  
1443 ## Notify the manager process (barrier end).
1444 0 print {$_DAT_W_SOCK} OUTPUT_E_SYN.$LF . $_chn.$LF;
1445  
1446 ## Wait until all workers from (task_id 0) have un-synced.
1447 0 ▶ MCE::Util::_sock_ready($_BSB_W_SOCK, -1) if $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 0 0 0
1448 0 MCE::Util::_sysread($_BSB_W_SOCK, $_buf, 1);
1449  
1450 0 return;
1451 }
1452  
1453 0 ▶sub yield {
Subroutine yield: not called CC=8 SCAR=42.8
Pod undocumented
1454 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1455  
1456 0 ▶ return unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
1457  
1458 0 my $_chn = $self->{_chn};
1459 0 my $_DAT_LOCK = $self->{_dat_lock};
1460 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1461 0 my $_DAU_W_SOCK = $self->{_dat_w_sock}->[$_chn];
1462 0 my $_lock_chn = $self->{_lock_chn};
1463 0 my $_delay;
1464  
1465 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1466 0 ▶ local $/ = $LF if (!$/ || $/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if not $/ or $/ ne $MCE::LF 0 0 0
Condition0%0/3
not $/ or $/ ne $MCE::LF
l!l&&r!l&&!r
000
MC/DC0%0/2
not $/ or $/ ne $MCE::LF
not $/ $/ ne $MCE::LF
Truth table0%0/3
not(A) or B
A= not $/B= $/ ne $MCE::LF
ABresult
1X1
011
000
1467  
1468 0 ▶ $_DAT_LOCK->lock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1469 0 print({$_DAT_W_SOCK} OUTPUT_I_DLY.$LF . $_chn.$LF),
1470 0 print({$_DAU_W_SOCK} $self->{_task_id}.$LF);
1471 0 chomp($_delay = <$_DAU_W_SOCK>);
1472 0 ▶ $_DAT_LOCK->unlock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1473  
1474 0 MCE::Util::_sleep( $_delay );
1475 }
1476  
1477 ###############################################################################
1478 ## ----------------------------------------------------------------------------
1479 ## Miscellaneous methods: abort exit sess_dir tmp_dir.
1480 ##
1481 ###############################################################################
1482  
1483 ## Abort current job.
1484  
1485 0 ▶sub abort {
Subroutine abort: not called CC=7 SCAR=40.3
Pod undocumented
1486 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1487  
1488 0 my $_QUE_R_SOCK = $self->{_que_r_sock};
1489 0 my $_QUE_W_SOCK = $self->{_que_w_sock};
1490 0 my $_abort_msg = $self->{_abort_msg};
1491  
1492 0 ▶ if (defined $_abort_msg) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_abort_msg) 0 0 0
1493 0 local $\ = undef;
1494  
1495 0 ▶ if ($_abort_msg > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_abort_msg > 0) 0 0 0
1496 0 MCE::Util::_sysread($_QUE_R_SOCK, my($_next), $_que_read_size);
1497 0 syswrite($_QUE_W_SOCK, pack($_que_template, 0, $_abort_msg));
1498 }
1499  
1500 0 ▶ if ($self->{_wid} > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_wid"} > 0) 0 0 0
1501 0 my $_chn = $self->{_chn};
1502 0 my $_DAT_LOCK = $self->{_dat_lock};
1503 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1504 0 my $_DAU_W_SOCK = $self->{_dat_w_sock}->[$_chn];
1505 0 my $_lock_chn = $self->{_lock_chn};
1506  
1507 0 ▶ $_DAT_LOCK->lock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1508 0 print {$_DAT_W_SOCK} OUTPUT_W_ABT.$LF . $_chn.$LF;
1509 0 ▶ $_DAT_LOCK->unlock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1510 }
1511 }
1512  
1513 0 return;
1514 }
1515  
1516 ## Worker exits from MCE.
1517  
1518 0 ▶sub exit {
Subroutine exit: not called CC=24 SCAR=64.0
Pod undocumented
1519 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1520  
1521 0 ▶ my $_exit_status = (defined $_[0]) ? $_[0] : $?;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 0 0 0
1522 0 ▶ my $_exit_msg = (defined $_[1]) ? $_[1] : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] ? : 0 0 0
1523 0 ▶ my $_exit_id = (defined $_[2]) ? $_[2] : $self->chunk_id;
Branch: 1 branch
BranchTrueFalseTotal
defined $_[2] ? : 0 0 0
1524  
1525 0 @_ = ();
1526  
1527 _croak('MCE::exit: method is not allowed by the manager process')
1528 0 ▶ unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
1529  
1530 0 my $_chn = $self->{_chn};
1531 0 my $_DAT_LOCK = $self->{_dat_lock};
1532 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1533 0 my $_DAU_W_SOCK = $self->{_dat_w_sock}->[$_chn];
1534 0 my $_lock_chn = $self->{_lock_chn};
1535 0 my $_task_id = $self->{_task_id};
1536  
1537 0 ▶ unless ( $self->{_exiting} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_exiting"}) 0 0 0
1538 0 $self->{_exiting} = 1;
1539  
1540 0 ▶ my $_pid = $self->{_is_thread} ? $$ .'.'. threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_is_thread'} ? : 0 0 0
1541 0 my $_max_retries = $self->{max_retries};
1542 0 my $_chunk_id = $self->{_chunk_id};
1543  
1544 0 ▶ if ( defined $self->{init_relay} && !$self->{_relayed} && !$_task_id &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"init_relay"} and not $self->{"_relayed"} and not $_task_id and exists $self->{"_wuf"} and $self->{"_pid"} eq $_pid) 0 0 0
Condition0%0/12
defined $self->{"init_relay"} and not $self->{"_relayed"} and not $_task_id and exists $self->{"_wuf"} and $self->{"_pid"} eq $_pid
!ll&&!rl&&r
000
defined $self->{"init_relay"} and not $self->{"_relayed"} and not $_task_id and exists $self->{"_wuf"}
!ll&&!rl&&r
000
defined $self->{"init_relay"} and not $self->{"_relayed"} and not $_task_id
!ll&&!rl&&r
000
defined $self->{"init_relay"} and not $self->{"_relayed"}
!ll&&!rl&&r
000
MC/DC0%0/5
defined $self->{"init_relay"} and not $self->{"_relayed"} and not $_task_id and exists $self->{"_wuf"} and $self->{"_pid"} eq $_pid
defined $self->{"init_relay"} not $self->{"_relayed"} not $_task_id exists $self->{"_wuf"} $self->{"_pid"} eq $_pid
Truth table0%0/6
A and not(B) and not(C) and D and E
A= defined $self->{"init_relay"}B= not $self->{"_relayed"}C= not $_task_idD= exists $self->{"_wuf"}E= $self->{"_pid"} eq $_pid
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1545 exists $self->{_wuf} && $self->{_pid} eq $_pid ) {
1546  
1547 0 ▶ $self->{_retry_cnt} = -1 unless defined( $self->{_retry_cnt} );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_retry_cnt"} 0 0 0
1548  
1549 0 ▶ if ( !$_max_retries || ++$self->{_retry_cnt} == $_max_retries ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_max_retries or ++$self->{"_retry_cnt"} == $_max_retries) 0 0 0
Condition0%0/3
not $_max_retries or ++$self->{"_retry_cnt"} == $_max_retries
l!l&&r!l&&!r
000
MC/DC0%0/2
not $_max_retries or ++$self->{"_retry_cnt"} == $_max_retries
not $_max_retries ++$self->{"_retry_cnt"} == $_max_retries
Truth table0%0/3
not(A) or B
A= not $_max_retriesB= ++$self->{"_retry_cnt"} == $_max_retries
ABresult
1X1
011
000
1550 0 ▶ MCE::relay { warn "Error: chunk $_chunk_id failed\n" if $_chunk_id };
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $_chunk_id 0 0 0
1551 }
1552 }
1553  
1554 ## Check for nested workers not yet joined.
1555 0 ▶ MCE::Child->finish('MCE') if $INC{'MCE/Child.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Child.pm"} 0 0 0
1556  
1557 MCE::Hobo->finish('MCE')
1558 0 ▶ if ( $INC{'MCE/Hobo.pm'} && MCE::Hobo->can('_clear') );
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Hobo.pm"} and "MCE::Hobo"->can("_clear") 0 0 0
Condition0%0/3
$INC{"MCE/Hobo.pm"} and "MCE::Hobo"->can("_clear")
!ll&&!rl&&r
000
MC/DC0%0/2
$INC{"MCE/Hobo.pm"} and "MCE::Hobo"->can("_clear")
$INC{"MCE/Hobo.pm"} "MCE::Hobo"->can("_clear")
Truth table0%0/3
A and B
A= $INC{"MCE/Hobo.pm"}B= "MCE::Hobo"->can("_clear")
ABresult
0X0
100
111
1559  
1560 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1561 0 my $_len = length $_exit_msg;
1562  
1563 0 $_exit_id =~ s/[\r\n][\r\n]*/ /mg;
1564 0 ▶ $_DAT_LOCK->lock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1565  
1566 0 ▶ if ($self->{_retry} && $self->{_retry}->[2]--) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_retry'} and $self->{'_retry'}[2]--) { } 0 0 0
Condition0%0/3
$self->{"_retry"} and $self->{"_retry"}[2]--
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"_retry"} and $self->{"_retry"}[2]--
$self->{"_retry"} $self->{"_retry"}[2]--
Truth table0%0/3
A and B
A= $self->{"_retry"}B= $self->{"_retry"}[2]--
ABresult
0X0
100
111
1567 0 $_exit_status = 0; my $_buf = $self->{freeze}($self->{_retry});
1568 0 print({$_DAT_W_SOCK} OUTPUT_W_EXT.$LF . $_chn.$LF),
1569 0 print({$_DAU_W_SOCK}
1570 0 $_task_id.$LF . $self->{_wid}.$LF . $self->{_exit_pid}.$LF .
1571 $_exit_status.$LF . $_exit_id.$LF . $_len.$LF . $_exit_msg .
1572 length($_buf).$LF, $_buf
1573 );
1574 }
1575 else {
1576 0 print({$_DAT_W_SOCK} OUTPUT_W_EXT.$LF . $_chn.$LF),
1577 0 print({$_DAU_W_SOCK}
1578 0 $_task_id.$LF . $self->{_wid}.$LF . $self->{_exit_pid}.$LF .
1579 $_exit_status.$LF . $_exit_id.$LF . $_len.$LF . $_exit_msg .
1580 '0'.$LF
1581 );
1582 }
1583  
1584 0 ▶ $_DAT_LOCK->unlock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1585 }
1586  
1587 0 _exit($self);
1588 }
1589  
1590 ## Return the session dir, made on demand.
1591  
1592 0 ▶sub sess_dir {
Subroutine sess_dir: not called CC=10 SCAR=47.0
Pod undocumented
1593 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1594 0 ▶ return $self->{_sess_dir} if defined $self->{_sess_dir};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"_sess_dir"} 0 0 0
1595  
1596 0 ▶ if ($self->{_wid} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_wid'} == 0) { } 0 0 0
1597 0 ▶ $self->{_sess_dir} = $self->{_spawned} ? _make_sessdir($self) : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_spawned'} ? : 0 0 0
1598 }
1599 else {
1600 0 my $_chn = $self->{_chn};
1601 0 my $_DAT_LOCK = $self->{_dat_lock};
1602 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1603 0 my $_DAU_W_SOCK = $self->{_dat_w_sock}->[$_chn];
1604 0 my $_lock_chn = $self->{_lock_chn};
1605 0 my $_sess_dir;
1606  
1607 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1608 0 ▶ local $/ = $LF if (!$/ || $/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if not $/ or $/ ne $MCE::LF 0 0 0
Condition0%0/3
not $/ or $/ ne $MCE::LF
l!l&&r!l&&!r
000
MC/DC0%0/2
not $/ or $/ ne $MCE::LF
not $/ $/ ne $MCE::LF
Truth table0%0/3
not(A) or B
A= not $/B= $/ ne $MCE::LF
ABresult
1X1
011
000
1609  
1610 0 ▶ $_DAT_LOCK->lock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1611 0 print({$_DAT_W_SOCK} OUTPUT_S_DIR.$LF . $_chn.$LF);
1612 0 chomp($_sess_dir = <$_DAU_W_SOCK>);
1613 0 ▶ $_DAT_LOCK->unlock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1614  
1615 0 $self->{_sess_dir} = $_sess_dir;
1616 }
1617 }
1618  
1619 ## Return the temp dir, made on demand.
1620  
1621 31 ▶sub tmp_dir {
Subroutine tmp_dir: called CC=9 SCAR=38.5
Pod undocumented
1622 31 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 31 0 31
1623 31 ▶ return $self->{tmp_dir} if defined $self->{tmp_dir};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"tmp_dir"} 0 31 31
1624  
1625 31 ▶ if ($self->{_wid} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_wid'} == 0) { } 31 0 31
1626 31 $self->{tmp_dir} = MCE::Signal::_make_tmpdir();
1627 }
1628 else {
1629 0 my $_chn = $self->{_chn};
1630 0 my $_DAT_LOCK = $self->{_dat_lock};
1631 0 my $_DAT_W_SOCK = $self->{_dat_w_sock}->[0];
1632 0 my $_DAU_W_SOCK = $self->{_dat_w_sock}->[$_chn];
1633 0 my $_lock_chn = $self->{_lock_chn};
1634 0 my $_tmp_dir;
1635  
1636 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1637 0 ▶ local $/ = $LF if (!$/ || $/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if not $/ or $/ ne $MCE::LF 0 0 0
Condition0%0/3
not $/ or $/ ne $MCE::LF
l!l&&r!l&&!r
000
MC/DC0%0/2
not $/ or $/ ne $MCE::LF
not $/ $/ ne $MCE::LF
Truth table0%0/3
not(A) or B
A= not $/B= $/ ne $MCE::LF
ABresult
1X1
011
000
1638  
1639 0 ▶ $_DAT_LOCK->lock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1640 0 print({$_DAT_W_SOCK} OUTPUT_T_DIR.$LF . $_chn.$LF);
1641 0 chomp($_tmp_dir = <$_DAU_W_SOCK>);
1642 0 ▶ $_DAT_LOCK->unlock() if $_lock_chn;
Branch: 1 branch
BranchTrueFalseTotal
if $_lock_chn 0 0 0
1643  
1644 0 $self->{tmp_dir} = $_tmp_dir;
1645 }
1646 }
1647  
1648 ###############################################################################
1649 ## ----------------------------------------------------------------------------
1650 ## Methods for serializing data from workers to the main process.
1651 ##
1652 ###############################################################################
1653  
1654 ## Do method. Additional arguments are optional.
1655  
1656 133 ▶sub do {
Subroutine do: called CC=7 SCAR=20.5
Pod undocumented
1657 133 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 130 3 133
1658 133 ▶ my $_pkg = caller() eq 'MCE' ? caller(1) : caller();
Branch: 1 branch
BranchTrueFalseTotal
caller() eq 'MCE' ? : 0 133 133
1659  
1660 133 ▶ _croak('MCE::do: (code ref) is not supported')
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "CODE" 0 133 133
1661 if (ref $_[0] eq 'CODE');
1662 133 ▶ _croak('MCE::do: (callback) is not specified')
Branch: 1 branch
BranchTrueFalseTotal
unless defined(my $_func = shift()) 0 133 133
1663 unless (defined ( my $_func = shift ));
1664  
1665 133 ▶ $_func = $_pkg.'::'.$_func if (index($_func, ':') < 0);
Branch: 1 branch
BranchTrueFalseTotal
if (index($_func, ":") == -1) 133 0 133
1666  
1667 133 ▶ if ($self->{_wid}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_wid'}) { } 133 0 133
1668 133 return _do_callback($self, $_func, [ @_ ]);
1669 }
1670 else {
1671 94 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1672 0 return $_func->(@_);
1673 }
1674 }
1675  
1676 ## Gather method.
1677  
1678 365 ▶sub gather {
Subroutine gather: called CC=3 SCAR=11.4
Pod undocumented
1679 365 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 365 0 365
1680  
1681 _croak('MCE::gather: method is not allowed by the manager process')
1682 365 ▶ unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 365 365
1683  
1684 365 return _do_gather($self, [ @_ ]);
1685 }
1686  
1687 ## Sendto method.
1688  
1689 {
1690 94 my %_sendto_lkup = (
1691 'file' => SENDTO_FILEV1, 'stderr' => SENDTO_STDERR,
1692 'file:' => SENDTO_FILEV2, 'stdout' => SENDTO_STDOUT,
1693 'fd:' => SENDTO_FD,
1694 );
1695  
1696 94 my $_v2_regx = qr/^([^:]+:)(.+)/;
1697  
1698 0 ▶ sub sendto {
Subroutine sendto: not called CC=25 SCAR=64.8
Pod undocumented
1699  
1700 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1701 0 my $_to = shift;
1702  
1703 _croak('MCE::sendto: method is not allowed by the manager process')
1704 0 ▶ unless ($self->{_wid});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_wid"} 0 0 0
1705  
1706 0 ▶ return unless (defined $_[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 0 0 0
1707  
1708 my $_dest = exists $_sendto_lkup{ lc($_to) }
1709 0 ▶ ? $_sendto_lkup{ lc($_to) } : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $_sendto_lkup{lc $_to} ? : 0 0 0
1710 0 my $_value;
1711  
1712 0 ▶ if (!defined $_dest) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_dest) 0 0 0
1713 0 my $_fd;
1714  
1715 0 ▶ if (ref($_to) && ( defined ($_fd = fileno($_to)) ||
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_to and defined($_fd = fileno $_to) || defined($_fd = eval { do { $_to->fileno } })) { } 0 0 0
elsif (builtin::reftype($_to) eq 'GLOB') { } 0 0 0
Condition0%0/6
ref $_to and defined($_fd = fileno $_to) || defined($_fd = eval { do { $_to->fileno } })
!ll&&!rl&&r
000
defined($_fd = fileno $_to) or defined($_fd = eval { do { $_to->fileno } })
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_to and defined($_fd = fileno $_to) || defined($_fd = eval { do { $_to->fileno } })
ref $_to defined($_fd = fileno $_to) defined($_fd = eval { do { $_to->fileno } })
Truth table0%0/4
A and B or C
A= ref $_toB= defined($_fd = fileno $_to)C= defined($_fd = eval { do { $_to->fileno } })
ABCresult
0XX0
1000
11X1
1011
1716 0 defined ($_fd = eval { $_to->fileno }) )) {
1717  
1718 0 ▶ if (my $_ob = tied *{ $_to }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_ob = tied *{$_to;}) 0 0 0
1719 0 ▶ if (ref $_ob eq 'IO::TieCombine::Handle') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ob eq "IO::TieCombine::Handle") 0 0 0
1720 0 ▶ $_fd = 1 if (lc($_ob->{slot_name}) eq 'stdout');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stdout" 0 0 0
1721 0 ▶ $_fd = 2 if (lc($_ob->{slot_name}) eq 'stderr');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stderr" 0 0 0
1722 }
1723 }
1724  
1725 0 ▶ my $_data_ref = (scalar @_ == 1) ? \(''.$_[0]) : \join('', @_);
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ == 1 ? : 0 0 0
1726 0 return _do_send_glob($self, $_to, $_fd, $_data_ref);
1727 }
1728 elsif (reftype($_to) eq 'GLOB') {
1729 0 return _croak('Cannot write to filehandle');
1730 }
1731  
1732 0 ▶ if (defined $_to && $_to =~ /$_v2_regx/o) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_to and $_to =~ /$_v2_regx/o) 0 0 0
Condition0%0/3
defined $_to and $_to =~ /$_v2_regx/o
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_to and $_to =~ /$_v2_regx/o
defined $_to $_to =~ /$_v2_regx/o
Truth table0%0/3
A and B
A= defined $_toB= $_to =~ /$_v2_regx/o
ABresult
0X0
100
111
1733 $_dest = exists $_sendto_lkup{ lc($1) }
1734 0 ▶ ? $_sendto_lkup{ lc($1) } : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $_sendto_lkup{lc $1} ? : 0 0 0
1735 0 $_value = $2;
1736 }
1737  
1738 0 ▶ if (!defined $_dest || ( !defined $_value && (
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_dest or not defined $_value and $_dest == 1 || $_dest == 4) 0 0 0
Condition0%0/9
not defined $_dest or not defined $_value and $_dest == 1 || $_dest == 4
l!l&&r!l&&!r
000
not defined $_value and $_dest == 1 || $_dest == 4
!ll&&!rl&&r
000
$_dest == 1 or $_dest == 4
l!l&&r!l&&!r
000
MC/DC0%0/4
not defined $_dest or not defined $_value and $_dest == 1 || $_dest == 4
not defined $_dest not defined $_value $_dest == 1 $_dest == 4
Truth table0%0/5
not(A) or not(B) and C or D
A= not defined $_destB= not defined $_valueC= $_dest == 1D= $_dest == 4
ABCDresult
1XXX1
011X1
01011
00XX0
01000
1739 $_dest == SENDTO_FILEV2 || $_dest == SENDTO_FD
1740 ))) {
1741 0 my $_msg = "\n";
1742 0 $_msg .= "MCE::sendto: improper use of method\n";
1743 0 $_msg .= "\n";
1744 0 $_msg .= "## usage:\n";
1745 0 $_msg .= "## ->sendto(\"stderr\", ...);\n";
1746 0 $_msg .= "## ->sendto(\"stdout\", ...);\n";
1747 0 $_msg .= "## ->sendto(\"file:/path/to/file\", ...);\n";
1748 0 $_msg .= "## ->sendto(\"fd:2\", ...);\n";
1749 0 $_msg .= "\n";
1750  
1751 0 _croak($_msg);
1752 }
1753 }
1754  
1755 0 ▶ if ($_dest == SENDTO_FILEV1) { # sendto 'file', $a, $path
Branch: 1 branch
BranchTrueFalseTotal
if ($_dest == 0) 0 0 0
1756 0 ▶ return if (!defined $_[1] || @_ > 2); # Please switch to using V2
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_[1] or @_ > 2 0 0 0
Condition0%0/3
not defined $_[1] or @_ > 2
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $_[1] or @_ > 2
not defined $_[1] @_ > 2
Truth table0%0/3
not(A) or B
A= not defined $_[1]B= @_ > 2
ABresult
1X1
011
000
1757 0 $_value = $_[1]; delete $_[1]; # sendto 'file:/path', $a
1758 0 $_dest = SENDTO_FILEV2;
1759 }
1760  
1761 0 return _do_send($self, $_dest, $_value, @_);
1762 }
1763 }
1764  
1765 ###############################################################################
1766 ## ----------------------------------------------------------------------------
1767 ## Functions for serializing print, printf and say statements.
1768 ##
1769 ###############################################################################
1770  
1771 94 ▶sub print {
Subroutine print: not called CC=13 SCAR=51.4
Pod undocumented
1772 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1773 0 my ($_fd, $_glob, $_data);
1774  
1775 0 ▶ if (ref($_[0]) && ( defined ($_fd = fileno($_[0])) ||
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { } 0 0 0
elsif (builtin::reftype($_[0]) eq 'GLOB') { } 0 0 0
Condition0%0/6
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
!ll&&!rl&&r
000
defined($_fd = fileno $_[0]) or defined($_fd = eval { do { $_[0]->fileno } })
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
ref $_[0] defined($_fd = fileno $_[0]) defined($_fd = eval { do { $_[0]->fileno } })
Truth table0%0/4
A and B or C
A= ref $_[0]B= defined($_fd = fileno $_[0])C= defined($_fd = eval { do { $_[0]->fileno } })
ABCresult
0XX0
1000
11X1
1011
1776 0 defined ($_fd = eval { $_[0]->fileno }) )) {
1777  
1778 0 ▶ if (my $_ob = tied *{ $_[0] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_ob = tied *{$_[0];}) 0 0 0
1779 0 ▶ if (ref $_ob eq 'IO::TieCombine::Handle') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ob eq "IO::TieCombine::Handle") 0 0 0
1780 0 ▶ $_fd = 1 if (lc($_ob->{slot_name}) eq 'stdout');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stdout" 0 0 0
1781 0 ▶ $_fd = 2 if (lc($_ob->{slot_name}) eq 'stderr');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stderr" 0 0 0
1782 }
1783 }
1784  
1785 0 $_glob = shift;
1786 }
1787 elsif (reftype($_[0]) eq 'GLOB') {
1788 0 return _croak('Cannot write to filehandle');
1789 }
1790  
1791 0 ▶ $_data = join('', scalar @_ ? @_ : $_);
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ ? : 0 0 0
1792  
1793 0 ▶ return _do_send_glob($self, $_glob, $_fd, \$_data) if $_fd;
Branch: 1 branch
BranchTrueFalseTotal
if $_fd 0 0 0
1794 0 ▶ return _do_send($self, SENDTO_STDOUT, undef, \$_data) if $self->{_wid};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
1795 0 return _do_send_glob($self, \*STDOUT, 1, \$_data);
1796 }
1797  
1798 0 ▶sub printf {
Subroutine printf: not called CC=14 SCAR=53.5
Pod undocumented
1799 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1800 0 my ($_fd, $_glob, $_fmt, $_data);
1801  
1802 0 ▶ if (ref($_[0]) && ( defined ($_fd = fileno($_[0])) ||
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { } 0 0 0
elsif (builtin::reftype($_[0]) eq 'GLOB') { } 0 0 0
Condition0%0/6
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
!ll&&!rl&&r
000
defined($_fd = fileno $_[0]) or defined($_fd = eval { do { $_[0]->fileno } })
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
ref $_[0] defined($_fd = fileno $_[0]) defined($_fd = eval { do { $_[0]->fileno } })
Truth table0%0/4
A and B or C
A= ref $_[0]B= defined($_fd = fileno $_[0])C= defined($_fd = eval { do { $_[0]->fileno } })
ABCresult
0XX0
1000
11X1
1011
1803 0 defined ($_fd = eval { $_[0]->fileno }) )) {
1804  
1805 0 ▶ if (my $_ob = tied *{ $_[0] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_ob = tied *{$_[0];}) 0 0 0
1806 0 ▶ if (ref $_ob eq 'IO::TieCombine::Handle') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ob eq "IO::TieCombine::Handle") 0 0 0
1807 0 ▶ $_fd = 1 if (lc($_ob->{slot_name}) eq 'stdout');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stdout" 0 0 0
1808 0 ▶ $_fd = 2 if (lc($_ob->{slot_name}) eq 'stderr');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stderr" 0 0 0
1809 }
1810 }
1811  
1812 0 $_glob = shift;
1813 }
1814 elsif (reftype($_[0]) eq 'GLOB') {
1815 0 return _croak('Cannot write to filehandle');
1816 }
1817  
1818 0 ▶ $_fmt = shift || '%s';
Condition0%0/2
shift() || '%s'
l!l
00
MC/DC0%0/1
shift() || '%s'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
1819 0 ▶ $_data = _sprintf($_fmt, scalar @_ ? @_ : $_);
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ ? : 0 0 0
1820  
1821 0 ▶ return _do_send_glob($self, $_glob, $_fd, \$_data) if $_fd;
Branch: 1 branch
BranchTrueFalseTotal
if $_fd 0 0 0
1822 0 ▶ return _do_send($self, SENDTO_STDOUT, undef, \$_data) if $self->{_wid};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
1823 0 return _do_send_glob($self, \*STDOUT, 1, \$_data);
1824 }
1825  
1826 0 ▶sub say {
Subroutine say: not called CC=13 SCAR=52.0
Pod undocumented
1827 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1828 0 my ($_fd, $_glob, $_data);
1829  
1830 0 ▶ if (ref($_[0]) && ( defined ($_fd = fileno($_[0])) ||
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { } 0 0 0
elsif (builtin::reftype($_[0]) eq 'GLOB') { } 0 0 0
Condition0%0/6
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
!ll&&!rl&&r
000
defined($_fd = fileno $_[0]) or defined($_fd = eval { do { $_[0]->fileno } })
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })
ref $_[0] defined($_fd = fileno $_[0]) defined($_fd = eval { do { $_[0]->fileno } })
Truth table0%0/4
A and B or C
A= ref $_[0]B= defined($_fd = fileno $_[0])C= defined($_fd = eval { do { $_[0]->fileno } })
ABCresult
0XX0
1000
11X1
1011
1831 0 defined ($_fd = eval { $_[0]->fileno }) )) {
1832  
1833 0 ▶ if (my $_ob = tied *{ $_[0] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_ob = tied *{$_[0];}) 0 0 0
1834 0 ▶ if (ref $_ob eq 'IO::TieCombine::Handle') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_ob eq "IO::TieCombine::Handle") 0 0 0
1835 0 ▶ $_fd = 1 if (lc($_ob->{slot_name}) eq 'stdout');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stdout" 0 0 0
1836 0 ▶ $_fd = 2 if (lc($_ob->{slot_name}) eq 'stderr');
Branch: 1 branch
BranchTrueFalseTotal
if lc $_ob->{"slot_name"} eq "stderr" 0 0 0
1837 }
1838 }
1839  
1840 0 $_glob = shift;
1841 }
1842 elsif (reftype($_[0]) eq 'GLOB') {
1843 0 return _croak('Cannot write to filehandle');
1844 }
1845  
1846 0 ▶ $_data = join('', scalar @_ ? @_ : $_) . "\n";
Branch: 1 branch
BranchTrueFalseTotal
scalar @_ ? : 0 0 0
1847  
1848 0 ▶ return _do_send_glob($self, $_glob, $_fd, \$_data) if $_fd;
Branch: 1 branch
BranchTrueFalseTotal
if $_fd 0 0 0
1849 0 ▶ return _do_send($self, SENDTO_STDOUT, undef, \$_data) if $self->{_wid};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_wid"} 0 0 0
1850 0 return _do_send_glob($self, \*STDOUT, 1, \$_data);
1851 }
1852  
1853 ###############################################################################
1854 ## ----------------------------------------------------------------------------
1855 ## Private methods.
1856 ##
1857 ###############################################################################
1858  
1859 73 ▶sub _exit {
Subroutine _exit: called CC=11 SCAR=35.7
1860 73 my $self = shift;
1861 73 ▶ my $_has_guard = (exists $self->{_guard} && $self->{_guard}->[0]) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'_guard'} && $self->{'_guard'}[0] ? : 0 73 73
Condition33%1/3
exists $self->{"_guard"} and $self->{"_guard"}[0]
!ll&&!rl&&r
7300
MC/DC0%0/2
exists $self->{"_guard"} and $self->{"_guard"}[0]
exists $self->{"_guard"} $self->{"_guard"}[0]
Truth table33%1/3
A and B
A= exists $self->{"_guard"}B= $self->{"_guard"}[0]
ABresult
0X0
100
111
1862  
1863 0 ▶ @{ $self->{_guard} } = () if $_has_guard;
Branch: 1 branch
BranchTrueFalseTotal
if $_has_guard 0 73 73
1864 73 delete $self->{_wuf}; _end();
1865  
1866 ## Exit thread/child process.
1867 73 ▶ $SIG{__DIE__} = sub {} unless $_tid;
Subroutine __ANON__: not called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $_tid 73 0 73
1868 73 ▶ $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
1869  
1870 73 ▶ threads->exit(0) if $self->{use_threads};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"use_threads"} 0 73 73
1871  
1872 73 ▶ if (! $_tid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_tid) 73 0 73
1873 0 ▶ $SIG{HUP} = $SIG{INT} = $SIG{QUIT} = $SIG{TERM} = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
1874 0 ▶ $SIG{$_[0]} = $SIG{INT} = $SIG{TERM} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
1875  
1876 0 ▶ CORE::kill($_[0], getppid())
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] eq "INT" || $_[0] eq "TERM" and $^O ne "MSWin32" 0 0 0
Condition0%0/6
$_[0] eq "INT" || $_[0] eq "TERM" and $^O ne "MSWin32"
!ll&&!rl&&r
000
$_[0] eq "INT" or $_[0] eq "TERM"
l!l&&r!l&&!r
000
MC/DC0%0/3
$_[0] eq "INT" || $_[0] eq "TERM" and $^O ne "MSWin32"
$_[0] eq "INT" $_[0] eq "TERM" $^O ne "MSWin32"
Truth table0%0/5
A or B and C
A= $_[0] eq "INT"B= $_[0] eq "TERM"C= $^O ne "MSWin32"
ABCresult
00X0
1X00
0100
1X11
0111
1877 if (($_[0] eq 'INT' || $_[0] eq 'TERM') && $^O ne 'MSWin32');
1878  
1879 0 CORE::kill('KILL', $$);
1880 73 };
1881 }
1882  
1883 73 ▶ if ($self->{posix_exit} && !$_has_guard && !$_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"posix_exit"} and not $_has_guard and not $_is_MSWin32) 0 73 73
Condition33%2/6
$self->{"posix_exit"} and not $_has_guard and not $_is_MSWin32
!ll&&!rl&&r
7300
$self->{"posix_exit"} and not $_has_guard
!ll&&!rl&&r
7300
MC/DC0%0/3
$self->{"posix_exit"} and not $_has_guard and not $_is_MSWin32
$self->{"posix_exit"} not $_has_guard not $_is_MSWin32
Truth table25%1/4
A and not(B) and not(C)
A= $self->{"posix_exit"}B= not $_has_guardC= not $_is_MSWin32
ABCresult
0XX0
10X0
1100
1111
1884 0 eval { MCE::Mutex::Channel::_destroy() };
1885 0 ▶ POSIX::_exit(0) if $INC{'POSIX.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"POSIX.pm"} 0 0 0
1886 0 CORE::kill('KILL', $$);
1887 }
1888  
1889 73 CORE::exit(0);
1890 }
1891  
1892 140 ▶sub _get_max_workers {
Subroutine _get_max_workers: called CC=4 SCAR=14.0
1893 140 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 140 140
1894  
1895 140 ▶ if (defined $self->{user_tasks}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"user_tasks"}) 96 44 140
1896 96 ▶ if (defined $self->{user_tasks}->[0]->{max_workers}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"user_tasks"}[0]{"max_workers"}) 96 0 96
1897 96 return $self->{user_tasks}->[0]->{max_workers};
1898 }
1899 }
1900  
1901 44 return $self->{max_workers};
1902 }
1903  
1904 0 ▶sub _make_sessdir {
Subroutine _make_sessdir: not called CC=11 SCAR=48.8
1905 0 ▶ my $self = shift; $self = $MCE unless ref($self);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 0 0
1906  
1907 0 my $_sess_dir = $self->{_sess_dir};
1908  
1909 0 ▶ unless (defined $_sess_dir) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_sess_dir) 0 0 0
1910 $self->{tmp_dir} = MCE::Signal::_make_tmpdir()
1911 0 ▶ unless defined $self->{tmp_dir};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"tmp_dir"} 0 0 0
1912  
1913 0 ▶ my $_mce_tid = $INC{'threads.pm'} ? threads->tid() : '';
Branch: 1 branch
BranchTrueFalseTotal
$INC{'threads.pm'} ? : 0 0 0
1914 0 ▶ $_mce_tid = '' unless defined $self->{_mce_tid};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"_mce_tid"} 0 0 0
1915  
1916 0 my $_mce_sid = $$ .'.'. $_mce_tid .'.'. (++$_mce_count);
1917 0 my $_tmp_dir = $self->{tmp_dir};
1918  
1919 0 ▶ _croak("MCE::sess_dir: (tmp_dir) is not defined")
Branch: 1 branch
BranchTrueFalseTotal
if not defined $_tmp_dir or $_tmp_dir eq "" 0 0 0
Condition0%0/3
not defined $_tmp_dir or $_tmp_dir eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $_tmp_dir or $_tmp_dir eq ""
not defined $_tmp_dir $_tmp_dir eq ""
Truth table0%0/3
not(A) or B
A= not defined $_tmp_dirB= $_tmp_dir eq ""
ABresult
1X1
011
000
1920 if (!defined $_tmp_dir || $_tmp_dir eq '');
1921 0 ▶ _croak("MCE::sess_dir: ($_tmp_dir) is not a directory or does not exist")
Branch: 1 branch
BranchTrueFalseTotal
unless -d $_tmp_dir 0 0 0
1922 unless (-d $_tmp_dir);
1923 0 ▶ _croak("MCE::sess_dir: ($_tmp_dir) is not writeable")
Branch: 1 branch
BranchTrueFalseTotal
unless -w $_tmp_dir 0 0 0
1924 unless (-w $_tmp_dir);
1925  
1926 0 my $_cnt = 0; $_sess_dir = "$_tmp_dir/$_mce_sid";
1927  
1928 0 ▶ $_sess_dir = "$_tmp_dir/$_mce_sid." . (++$_cnt)
Branch: 1 branch
BranchTrueFalseTotal
mkdir $_sess_dir, 504 or do { $_sess_dir = "$_tmp_dir/$_mce_sid." . ++$_cnt } 0 0 0
1929 while ( !(mkdir $_sess_dir, 0770) );
1930 }
1931  
1932 0 return $_sess_dir;
1933 }
1934  
1935 0 ▶sub _sprintf {
Subroutine _sprintf: not called CC=1 SCAR=6.9
1936 0 my $_fmt = shift;
1937 # remove tainted'ness
1938 0 ($_fmt) = $_fmt =~ /(.*)/s;
1939  
1940 0 return sprintf("$_fmt", @_);
1941 }
1942  
1943 5 ▶sub _sync_buffer_to_array {
Subroutine _sync_buffer_to_array: called CC=4 SCAR=15.4
1944 5 my ($_buffer_ref, $_array_ref, $_chop_str) = @_;
1945  
1946 5 local $_; my $_cnt = 0;
1947  
1948 5 open my $_MEM_FH, '<', $_buffer_ref;
1949 5 binmode $_MEM_FH, ':raw';
1950  
1951 5 ▶ unless (length $_chop_str) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_chop_str) { } 0 5 5
1952 5 ▶ $_array_ref->[$_cnt++] = $_ while (<$_MEM_FH>);
Branch: 1 branch
BranchTrueFalseTotal
defined($_ = readline $_MEM_FH) and do { $$_array_ref[$_cnt++] = $_ } 45 5 50
1953 }
1954 else {
1955 0 $_array_ref->[$_cnt++] = <$_MEM_FH>;
1956 0 ▶ while (<$_MEM_FH>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $_MEM_FH)) 0 0 0
1957 0 $_array_ref->[$_cnt ] = $_chop_str;
1958 0 $_array_ref->[$_cnt++] .= $_;
1959 }
1960 }
1961  
1962 5 close $_MEM_FH;
1963 5 weaken $_MEM_FH;
1964  
1965 5 return;
1966 }
1967  
1968 192 ▶sub _sync_params {
Subroutine _sync_params: called CC=8 SCAR=23.4
1969 192 my ($self, $_params_ref) = @_;
1970 192 my $_requires_shutdown = 0;
1971  
1972 192 ▶ if (defined $_params_ref->{init_relay} && !defined $self->{init_relay}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_params_ref->{"init_relay"} and not defined $self->{"init_relay"}) 0 192 192
Condition33%1/3
defined $_params_ref->{"init_relay"} and not defined $self->{"init_relay"}
!ll&&!rl&&r
19200
MC/DC0%0/2
defined $_params_ref->{"init_relay"} and not defined $self->{"init_relay"}
defined $_params_ref->{"init_relay"} not defined $self->{"init_relay"}
Truth table33%1/3
A and not(B)
A= defined $_params_ref->{"init_relay"}B= not defined $self->{"init_relay"}
ABresult
0X0
100
111
1973 0 $_requires_shutdown = 1;
1974 }
1975 192 for my $_p (qw( user_begin user_func user_end )) {
1976 576 ▶ if (defined $_params_ref->{$_p}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_params_ref->{$_p}) 0 576 576
1977 0 $self->{$_p} = delete $_params_ref->{$_p};
1978 0 $_requires_shutdown = 1;
1979 }
1980 }
1981 192 for my $_p (keys %{ $_params_ref }) {
1982 _croak("MCE::_sync_params: ($_p) is not a valid params argument")
1983 316 ▶ unless (exists $_params_allowed_args{$_p});
Branch: 1 branch
BranchTrueFalseTotal
unless exists $_params_allowed_args{$_p} 0 316 316
1984  
1985 316 $self->{$_p} = $_params_ref->{$_p};
1986 }
1987  
1988 192 ▶ return ($self->{_spawned}) ? $_requires_shutdown : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'_spawned'} ? : 81 111 192
1989 }
1990  
1991 ###############################################################################
1992 ## ----------------------------------------------------------------------------
1993 ## Dispatch methods.
1994 ##
1995 ###############################################################################
1996  
1997 73 ▶sub _dispatch {
Subroutine _dispatch: called CC=22 SCAR=43.6
1998 73 my @_args = @_; my $_is_thread = shift @_args;
1999 73 my $self = $MCE = $_args[0];
2000  
2001 ## To avoid (Scalars leaked: N) messages; fixed in Perl 5.12.x
2002 73 @_ = ();
2003  
2004 $ENV{'PERL_MCE_IPC'} = 'win32' if ( $_is_MSWin32 && (
2005 defined($self->{max_retries}) ||
2006 $INC{'MCE/Child.pm'} ||
2007 73 ▶ $INC{'MCE/Hobo.pm'}
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 and defined $self->{"max_retries"} || $INC{"MCE/Child.pm"} || $INC{"MCE/Hobo.pm"} 0 73 73
Condition11%1/9
$_is_MSWin32 and defined $self->{"max_retries"} || $INC{"MCE/Child.pm"} || $INC{"MCE/Hobo.pm"}
!ll&&!rl&&r
7300
defined $self->{"max_retries"} or $INC{"MCE/Child.pm"} or $INC{"MCE/Hobo.pm"}
l!l&&r!l&&!r
000
defined $self->{"max_retries"} or $INC{"MCE/Child.pm"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$_is_MSWin32 and defined $self->{"max_retries"} || $INC{"MCE/Child.pm"} || $INC{"MCE/Hobo.pm"}
$_is_MSWin32 defined $self->{"max_retries"} $INC{"MCE/Child.pm"} $INC{"MCE/Hobo.pm"}
Truth table20%1/5
A and B or C or D
A= $_is_MSWin32B= defined $self->{"max_retries"}C= $INC{"MCE/Child.pm"}D= $INC{"MCE/Hobo.pm"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
2008 ));
2009  
2010 73 delete $self->{_relayed};
2011  
2012 73 $self->{_is_thread} = $_is_thread;
2013 73 ▶ $self->{_pid} = $_is_thread ? $$ .'.'. threads->tid() : $$;
Branch: 1 branch
BranchTrueFalseTotal
$_is_thread ? : 0 73 73
2014  
2015 73 ▶ if (!$self->{use_threads}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"use_threads"}) 73 0 73
2016 73 ▶ MCE::Child->_clear() if $INC{'MCE/Child.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Child.pm"} 0 73 73
2017 73 ▶ MCE::Hobo->_clear() if $INC{'MCE/Hobo.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Hobo.pm"} 0 73 73
2018 }
2019  
2020 # Set the seed of the base generator uniquely between workers.
2021 # The new seed is computed using the current seed and ID value.
2022 # One may set the seed at the application level for predictable
2023 # results (non-thread workers only). Ditto for Math::Prime::Util,
2024 # Math::Random, Math::Random::MT::Auto, and PDL.
2025 #
2026 # MCE 1.892, 2024-06-08: Enable predictability running threads.
2027 # Output matches non-threads for CORE, Math::Prime::Util, and
2028 # Math::Random::MT::Auto. https://perlmonks.org/?node_id=11159834
2029  
2030 {
2031 73 my $_wid = $_args[1];
2032 73 my $_seed = abs($self->{_seed} - ($_wid * 100000)) % 2147483560;
2033  
2034 73 ▶ CORE::srand($_seed) if (!$self->{use_threads} || $] ge '5.020000'); # drand48
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"use_threads"} or $] ge "5.020000" 73 0 73
Condition33%1/3
not $self->{"use_threads"} or $] ge "5.020000"
l!l&&r!l&&!r
7300
MC/DC0%0/2
not $self->{"use_threads"} or $] ge "5.020000"
not $self->{"use_threads"} $] ge "5.020000"
Truth table33%1/3
not(A) or B
A= not $self->{"use_threads"}B= $] ge "5.020000"
ABresult
1X1
011
000
2035 73 ▶ Math::Prime::Util::srand($_seed) if $INC{'Math/Prime/Util.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"Math/Prime/Util.pm"} 0 73 73
2036  
2037 # [etj] identified a race condition in PDL running threads
2038 # https://perlmonks.org/?node_id=11159841
2039 73 ▶ if (!$self->{use_threads}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"use_threads"}) 73 0 73
2040 73 ▶ PDL::srand($_seed) if $INC{'PDL.pm'} && PDL->can('srand'); # PDL 2.062 ~ 2.089
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"PDL.pm"} and "PDL"->can("srand") 0 73 73
Condition33%1/3
$INC{"PDL.pm"} and "PDL"->can("srand")
!ll&&!rl&&r
7300
MC/DC0%0/2
$INC{"PDL.pm"} and "PDL"->can("srand")
$INC{"PDL.pm"} "PDL"->can("srand")
Truth table33%1/3
A and B
A= $INC{"PDL.pm"}B= "PDL"->can("srand")
ABresult
0X0
100
111
2041 73 ▶ PDL::srandom($_seed) if $INC{'PDL.pm'} && PDL->can('srandom'); # PDL 2.089_01+
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"PDL.pm"} and "PDL"->can("srandom") 0 73 73
Condition33%1/3
$INC{"PDL.pm"} and "PDL"->can("srandom")
!ll&&!rl&&r
7300
MC/DC0%0/2
$INC{"PDL.pm"} and "PDL"->can("srandom")
$INC{"PDL.pm"} "PDL"->can("srandom")
Truth table33%1/3
A and B
A= $INC{"PDL.pm"}B= "PDL"->can("srandom")
ABresult
0X0
100
111
2042 }
2043 }
2044  
2045 73 ▶ if (!$self->{use_threads} && $INC{'Math/Random.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"use_threads"} and $INC{"Math/Random.pm"}) 0 73 73
Condition33%1/3
not $self->{"use_threads"} and $INC{"Math/Random.pm"}
!ll&&!rl&&r
0730
MC/DC0%0/2
not $self->{"use_threads"} and $INC{"Math/Random.pm"}
not $self->{"use_threads"} $INC{"Math/Random.pm"}
Truth table33%1/3
not(A) and B
A= not $self->{"use_threads"}B= $INC{"Math/Random.pm"}
ABresult
0X0
100
111
2046 0 my ($_wid, $_cur_seed) = ($_args[1], Math::Random::random_get_seed());
2047  
2048 0 ▶ my $_new_seed = ($_cur_seed < 1073741781)
Branch: 1 branch
BranchTrueFalseTotal
$_cur_seed < 1073741781 ? : 0 0 0
2049 ? $_cur_seed + (($_wid * 100000) % 1073741780)
2050 : $_cur_seed - (($_wid * 100000) % 1073741780);
2051  
2052 0 Math::Random::random_set_seed($_new_seed, $_new_seed);
2053 }
2054  
2055 73 ▶ if ($INC{'Math/Random/MT/Auto.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"Math/Random/MT/Auto.pm"}) 0 73 73
2056 0 my ($_wid, $_cur_seed) = (
2057 $_args[1], Math::Random::MT::Auto::get_seed()->[0]
2058 );
2059 0 ▶ my $_new_seed = ($_cur_seed < 1073741781)
Branch: 1 branch
BranchTrueFalseTotal
$_cur_seed < 1073741781 ? : 0 0 0
2060 ? $_cur_seed + (($_wid * 100000) % 1073741780)
2061 : $_cur_seed - (($_wid * 100000) % 1073741780);
2062  
2063 0 Math::Random::MT::Auto::set_seed($_new_seed);
2064 }
2065  
2066 ## Run.
2067  
2068 73 _worker_main(@_args, \@_plugin_worker_init);
2069  
2070 73 _exit($self);
2071 }
2072  
2073 0 ▶sub _dispatch_thread {
Subroutine _dispatch_thread: not called CC=7 SCAR=40.3
2074 0 my ($self, $_wid, $_task, $_task_id, $_task_wid, $_params) = @_;
2075  
2076 0 @_ = (); local $_;
2077  
2078 0 my $_thr = threads->create( \&_dispatch,
2079 1, $self, $_wid, $_task, $_task_id, $_task_wid, $_params
2080 );
2081  
2082 0 ▶ _croak("MCE::_dispatch_thread: Failed to spawn worker $_wid: $!")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_thr 0 0 0
2083 if (!defined $_thr);
2084  
2085 ## Store into an available slot (restart), otherwise append to arrays.
2086 0 ▶ if (defined $_params) { for my $_i (0 .. @{ $self->{_tids} } - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_params) 0 0 0
2087 0 ▶ unless (defined $self->{_tids}->[$_i]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_tids"}[$_i]) 0 0 0
2088 0 $self->{_thrs}->[$_i] = $_thr;
2089 0 $self->{_tids}->[$_i] = $_thr->tid();
2090 0 return;
2091 }
2092 }}
2093  
2094 0 push @{ $self->{_thrs} }, $_thr;
2095 0 push @{ $self->{_tids} }, $_thr->tid();
2096  
2097 sleep $self->{spawn_delay}
2098 0 ▶ if defined($self->{spawn_delay}) && $self->{spawn_delay} > 0.0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0 0 0 0
Condition0%0/3
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
defined $self->{"spawn_delay"} $self->{"spawn_delay"} > 0
Truth table0%0/3
A and B
A= defined $self->{"spawn_delay"}B= $self->{"spawn_delay"} > 0
ABresult
0X0
100
111
2099  
2100 0 return;
2101 }
2102  
2103 321 ▶sub _dispatch_child {
Subroutine _dispatch_child: called CC=10 SCAR=29.8
2104 321 my ($self, $_wid, $_task, $_task_id, $_task_wid, $_params) = @_;
2105  
2106 321 @_ = (); local $_;
2107 321 my $_pid = fork();
2108  
2109 321 ▶ _croak("MCE::_dispatch_child: Failed to spawn worker $_wid: $!")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_pid 0 321 321
2110 if (!defined $_pid);
2111  
2112 321 ▶ _dispatch(0, $self, $_wid, $_task, $_task_id, $_task_wid, $_params)
Branch: 1 branch
BranchTrueFalseTotal
if $_pid == 0 73 248 321
2113 if ($_pid == 0);
2114  
2115 ## Store into an available slot (restart), otherwise append to array.
2116 0 ▶ if (defined $_params) { for my $_i (0 .. @{ $self->{_pids} } - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_params) 0 248 248
2117 0 ▶ unless (defined $self->{_pids}->[$_i]) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_pids"}[$_i]) 0 0 0
2118 0 $self->{_pids}->[$_i] = $_pid;
2119 0 return;
2120 }
2121 }}
2122  
2123 248 push @{ $self->{_pids} }, $_pid;
2124  
2125 248 ▶ if ($self->{loop_timeout} && !$_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"loop_timeout"} and not $_is_MSWin32) 0 248 248
Condition33%1/3
$self->{"loop_timeout"} and not $_is_MSWin32
!ll&&!rl&&r
24800
MC/DC0%0/2
$self->{"loop_timeout"} and not $_is_MSWin32
$self->{"loop_timeout"} not $_is_MSWin32
Truth table33%1/3
A and not(B)
A= $self->{"loop_timeout"}B= not $_is_MSWin32
ABresult
0X0
100
111
2126 0 $self->{_pids_t}{$_pid} = $_task_id;
2127 0 $self->{_pids_w}{$_pid} = $_wid;
2128 }
2129  
2130 sleep $self->{spawn_delay}
2131 248 ▶ if defined($self->{spawn_delay}) && $self->{spawn_delay} > 0.0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0 0 248 248
Condition33%1/3
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
!ll&&!rl&&r
24800
MC/DC0%0/2
defined $self->{"spawn_delay"} and $self->{"spawn_delay"} > 0
defined $self->{"spawn_delay"} $self->{"spawn_delay"} > 0
Truth table33%1/3
A and B
A= defined $self->{"spawn_delay"}B= $self->{"spawn_delay"} > 0
ABresult
0X0
100
111
2132  
2133 248 return;
2134 }
2135  
2136 94 1;
2137  
« MCE/Core/Input/Handle.pm ↑ Summary MCE/Core/Validation.pm »