Branch Coverage

blib/lib/MCE.pm
Criterion Covered Total %
branch 231 760 30.3


line true false branch
27 0 85 if ($^O eq 'MSWin32' and not $INC{'threads.pm'}) { }
0 170 elsif ($INC{'threads.pm'} and not $INC{'threads/shared.pm'}) { }
34 0 85 $INC{'threads.pm'} ? :
35 0 85 $_has_threads ? :
38 85 0 if ($] ge "5.008008" and not $INC{'PDL.pm'})
40 85 0 unless ($@)
43 85 0 if ($_encoder_ver - $_decoder_ver == 0)
50 0 85 if (not defined $_freeze)
112 0 85 $^O eq 'MSWin32' ? :
113 0 85 $^O =~ /mswin|mingw|msys|cygwin/i ? :
120 3 96 unless ref $self
126 62 1 unless ref $self
132 166 42 unless ref $self
163 0 0 if $_arg eq "max_workers"
164 0 0 if $_arg eq "chunk_size"
165 0 0 if $_arg eq "tmp_dir"
166 0 0 if $_arg eq "freeze"
167 0 0 if $_arg eq "thaw"
168 0 0 if $_arg eq "init_relay"
169 0 0 if $_arg eq "use_threads"
171 0 0 if ($_arg eq "export_const" or $_arg eq "const")
172 0 0 if (shift() eq 1)
182 0 0 if ($_arg eq "sereal")
183 0 0 if (shift() eq 0)
194 13 85 if $_imported++
265 0 0 if $INC{'threads.pm'}
269 0 0 if $_is_MSWin32 and $MCE::Signal::KILLED
273 0 0 if $_[0] and $_[0]{'_spawned'} and $_[0]{'_init_pid'} eq "$$.$_tid" and not $MCE::Signal::KILLED
280 65 20 unless defined $MCE
282 0 20 $MCE::MCE->{'_is_thread'} ? :
283 0 20 if exists $MCE::MCE->{'_wuf'} and $MCE::MCE->{'_pid'} eq $_pid
289 37 48 if $INC{'MCE/Flow.pm'}
290 4 81 if $INC{'MCE/Grep.pm'}
291 5 80 if $INC{'MCE/Loop.pm'}
292 4 81 if $INC{'MCE/Map.pm'}
293 12 73 if $INC{'MCE/Step.pm'}
294 10 75 if $INC{'MCE/Stream.pm'}
311 45 0 unless (exists $_plugin_list{$_ext_module})
319 45 0 if (ref $_ext_output_function eq "HASH")
322 545 0 unless exists $_plugin_function{$_p}
326 45 0 if ref $_ext_output_loop_begin eq "CODE"
328 45 0 if ref $_ext_output_loop_end eq "CODE"
330 35 10 if ref $_ext_worker_init eq "CODE"
359 0 0 if ("MCE"->wid == 0 or not $^S)
376 103 216 exists $self{'pkg'} ? :
390 0 319 if exists $_def->{$_pkg}{'INIT_RELAY'}
393 0 319 if exists $_def->{$_pkg}{'USE_THREADS'}
395 85 234 if (exists $self{'_module_instance'})
408 0 1637 unless exists $_valid_fields_new{$_p}
413 0 234 if (defined $self{'use_threads'}) { }
414 0 0 if (not $_has_threads and $self{'use_threads'})
424 0 234 $_has_threads ? :
427 234 0 unless (exists $self{'posix_exit'})
433 0 234 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'}
440 42 192 if (defined $self{'tmp_dir'})
442 0 42 unless -d $self{'tmp_dir'}
444 0 42 unless -w $self{'tmp_dir'}
447 103 131 if (defined $self{'user_tasks'})
449 0 103 unless ref $self{'user_tasks'} eq "ARRAY"
453 0 103 if $self{'user_tasks'}[0]{'init_relay'}
458 0 528 unless exists $_valid_fields_task{$_p}
460 0 159 unless scalar keys %{$_task;}
463 59 100 unless defined $_task->{'max_workers'}
465 159 0 unless defined $_task->{'use_threads'}
486 0 234 if $_is_MSWin32
489 0 234 ref $self{'input_data'} eq 'SCALAR' ? :
492 0 234 $INC{'MCE/Channel.pm'} ? :
234 0 "$$.$_tid" eq $_oid ? :
497 103 131 if (defined $self{'user_tasks'}) { }
505 186 48 $_total_workers < $_data_channels ? :
508 42 192 $_total_workers > $self{'_data_channels'} ? :
509 0 234 if $INC{'MCE/Child.pm'} or $INC{'MCE/Hobo.pm'}
511 234 0 if $MCE::MCE->{'_wid'} == 0
523 0 126 unless ref $self
528 0 126 if $self->{'_wid'}
531 0 126 if $self->{'_spawned'} or exists $self->{'_module_instance'}
533 0 126 if $_is_MSWin32
534 0 126 if $_has_threads and $_is_winenv
536 0 0 if $_tid and $MCE::_GMUTEX
537 0 126 if $_tid
541 0 126 if ($INC{'PDL.pm'})
543 0 0 unless $INC{'PDL/IO/Storable.pm'}
549 0 126 if ($INC{'LWP/UserAgent.pm'} and not $INC{'Net/HTTP.pm'})
554 0 126 if $INC{'MCE/Shared.pm'}
557 0 126 if (defined $self->{'sequence'}) { }
45 81 elsif (defined $self->{'input_data'}) { }
559 0 0 unless $INC{'MCE/Core/Input/Sequence.pm'}
563 45 0 if ($_ref =~ /^(?:ARRAY|HASH|GLOB|FileHandle|IO::)/) { }
0 0 elsif ($_ref eq 'CODE') { }
565 34 11 unless $INC{'MCE/Core/Input/Request.pm'}
569 0 0 unless $INC{'MCE/Core/Input/Iterator.pm'}
573 0 0 unless $INC{'MCE/Core/Input/Handle.pm'}
583 126 0 if (not defined $TOP_HDLR && ($TOP_HDLR->{'_mgr_live'} || $TOP_HDLR->{'_wid'})) { }
0 0 elsif (&refaddr($self) != &refaddr($TOP_HDLR)) { }
585 0 0 if ($_is_MSWin32 and defined $TOP_HDLR and $TOP_HDLR->{'_spawned'})
592 0 0 if $self->{'_data_channels'} > 4
593 0 0 if $self->{'_init_total_workers'} > 4
596 0 0 if ($_is_MSWin32 and $ENV{'PERL_MCE_IPC'} ne "win32")
615 0 126 if ($self->{'_lock_chn'})
632 0 126 unless ($^O =~ /linux|android|aix/)
636 24 102 if (defined $self->{'init_relay'})
637 9 15 unless ($INC{'MCE/Relay.pm'})
652 0 126 if ($self->{'loop_timeout'} and not $_is_MSWin32)
656 126 0 unless $_is_MSWin32
658 35 91 if (not defined $self->{'user_tasks'}) { }
661 0 35 if (defined $_use_threads and $_use_threads == 1) { }
688 0 114 if (defined $_tsk_use_threads and $_tsk_use_threads == 1) { }
704 0 56 if (defined $_tsk_use_threads and $_tsk_use_threads == 1) { }
740 61 0 if $MCE::MCE->{'_wid'} == 0
742 0 0 if $_tid and $MCE::_GMUTEX
754 0 106 unless ref $self
760 6 100 if (ref $_[0] eq 'HASH' and ref $_[1] eq 'HASH') { }
95 5 elsif (ref $_[0] eq 'HASH') { }
771 106 0 if (defined $_input_data) { }
0 0 elsif (not defined $_params_ref->{'input_data'} || defined $_params_ref->{'sequence'}) { }
787 0 0 unless defined $MCE::MCE->{'init_relay'}
799 0 0 unless ref $self
803 0 0 if ($_fcn eq 'forchunk') { }
0 0 elsif ($_fcn eq 'foreach') { }
0 0 elsif ($_fcn eq 'forseq') { }
804 0 0 unless $INC{'MCE/Candy.pm'}
808 0 0 unless $INC{'MCE/Candy.pm'}
812 0 0 unless $INC{'MCE/Candy.pm'}
818 0 0 if ($_fcn eq 'relay_lock' or $_fcn eq 'relay_recv') { }
0 0 elsif ($_fcn eq 'relay_final') { }
820 0 0 unless defined $MCE::MCE->{'init_relay'}
828 0 0 if ($_fcn eq 'last') { }
0 0 elsif ($_fcn eq 'next') { }
0 0 elsif ($_fcn eq 'pid') { }
0 0 elsif ($_fcn eq 'status') { }
830 0 0 unless $self->{'_wid'}
832 0 0 if defined $self->{'_last_jmp'}
841 0 0 unless $self->{'_wid'}
843 0 0 if defined $self->{'_next_jmp'}
851 0 0 if (defined $self->{'_pid'}) { }
0 0 elsif ($_has_threads and $self->{'use_threads'}) { }
864 0 0 if $self->{'_wid'}
866 0 0 defined $self->{'_wrk_status'} ? :
879 0 0 unless ref $self
884 0 0 if $self->{'_wid'}
897 0 0 defined $_task_id ? :
899 0 0 if defined $_task_id
900 0 0 if defined $_task_id
905 0 0 if (defined $_use_threads and $_use_threads == 1) { }
913 0 0 if (defined $self->{'spawn_delay'} and $self->{'spawn_delay'} > 0) { }
0 0 elsif ($_tid or $_is_MSWin32) { }
929 0 207 unless ref $self
932 0 207 if $self->{'_wid'}
936 81 126 if (ref $_[0] eq 'HASH') { }
937 81 0 defined $_[1] ? :
940 106 20 defined $_[0] ? :
946 154 53 defined $self->{'user_tasks'} ? :
952 0 207 if $self->{'_send_cnt'}
954 91 0 unless (defined $self->{'user_func'} or defined $_params_ref->{'user_func'})
963 187 20 if (defined $_params_ref and ref $_params_ref eq "HASH")
967 154 53 if ($_has_user_tasks)
969 0 154 if $self->{'user_tasks'}[0]{'input_data'}
971 0 154 if $self->{'user_tasks'}[0]{'use_slurpio'}
973 0 154 if $self->{'user_tasks'}[0]{'parallel_io'}
975 0 154 if $self->{'user_tasks'}[0]{'RS'}
977 0 207 if (ref $self->{'input_data'} eq "SCALAR")
978 0 0 if (&refaddr($self->{'input_data'}) != $self->{'_last_sref'})
984 0 207 if $_requires_shutdown
991 126 81 unless $self->{'_spawned'}
992 0 142 unless $self->{'_total_workers'}
997 142 0 if $MCE::MCE->{'_wid'} == 0
1005 0 142 $_has_user_tasks && $self->{'user_tasks'}[0]{'sequence'} ? :
1008 18 124 if (defined $_seq) { }
79 45 elsif (defined $self->{'input_data'}) { }
1010 18 0 ref $_seq eq 'ARRAY' ? :
1013 0 14 if $_has_user_tasks and $self->{'user_tasks'}[0]{'chunk_size'}
1025 18 0 if ($_step > 0) { }
1026 18 0 if $_abort_msg * $_chunk_size * abs($_step) + $_begin <= $_end
1029 0 0 if $_abort_msg * $_chunk_size * abs($_step) + $_end <= $_begin
1038 18 61 if ($_ref eq '') { }
40 21 elsif ($_ref eq 'ARRAY') { }
3 18 elsif ($_ref eq 'HASH') { }
18 0 elsif ($_ref =~ /^(?:GLOB|FileHandle|IO::)/) { }
0 0 elsif ($_ref eq 'CODE') { }
0 0 elsif ($_ref eq 'SCALAR') { }
1045 0 18 if (-s $_input_file == 0)
1046 0 0 if $_auto_shutdown == 1
1054 40 0 if ref $_input_data->[0] eq ""
1058 0 40 if (@{$_input_data;} == 0)
1059 0 0 if $_auto_shutdown == 1
1070 0 3 if (scalar keys %{$_input_data;} == 0)
1071 0 0 if $_auto_shutdown == 1
1095 0 0 if (length ${$self->{'input_data'};} == 0)
1096 0 0 if $_auto_shutdown == 1
1112 0 142 if ($_send_cnt) { }
1134 0 142 $self->{'progress'} ? :
1139 108 34 if ($_has_user_tasks)
1150 201 146 unless $self->{'_state'}[$_i]{'_task_id'}
1157 97 45 if (defined $_first_msg)
1165 282 146 if (not $_has_user_tasks or exists $_task0_wids{$_wid}) { }
1173 0 428 if defined $_submit_delay and $_submit_delay > 0
1183 142 0 if ($self->{'_total_running'} > 0)
1188 0 142 if $_is_MSWin32
1190 142 0 unless ($_send_cnt)
1192 0 142 if ($_is_MSWin32) { }
1211 97 45 if (not $_send_cnt and $_run_mode ne "nodata")
1213 97 0 if defined $self->{'_que_r_sock'}
1219 10 132 if ($_auto_shutdown or $self->{'_total_exited'}) { }
0 132 elsif ($INC{'MCE/Simple.pm'}) { }
0 132 elsif ($^S or $ENV{'PERL_IPERL_RUNNING'}) { }
1226 0 0 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'})
1234 0 0 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'})
1254 0 0 unless ref $self
1257 0 0 if $self->{'_wid'}
1259 0 0 if $self->{'_total_running'}
1262 0 0 if defined $self->{'input_data'} or defined $self->{'sequence'}
1264 0 0 if defined $self->{'user_tasks'}
1268 0 0 if (ref $_[0] eq 'ARRAY' or ref $_[0] eq 'HASH' or ref $_[0] eq 'PDL') { }
1276 0 0 unless defined $self->{'_send_cnt'}
1281 0 0 unless $self->{'_spawned'}
1284 0 0 if $self->{'_send_cnt'} >= $self->{'_task'}[0]{'_total_workers'}
1303 0 0 if defined $_submit_delay and $_submit_delay > 0
1316 0 61 unless ref $self
1322 0 61 unless $self->{'_spawned'}
1325 0 61 if ($MCE::Signal::KILLED)
1326 0 0 if (defined $self->{'_sess_dir'})
1328 0 0 if -d $_sess_dir
1336 0 61 if $self->{'_send_cnt'}
1346 61 0 if (defined $TOP_HDLR and &refaddr($self) == &refaddr($TOP_HDLR))
1352 0 0 if $_has_threads and $_is_winenv and not $_no_lock
1362 61 0 if (@{$self->{'_pids'};} > 0)
1365 146 61 if $_list->[$i]
1368 0 61 if (@{$self->{'_thrs'};} > 0)
1371 0 0 if $_list->[$i]
1390 0 61 if defined $_sess_dir and -d $_sess_dir
1401 0 61 if ($self->{'loop_timeout'})
1416 0 0 unless ref $self
1418 0 0 unless $self->{'_wid'}
1423 0 0 if $self->{'_task_id'} > 0
1431 0 0 if defined $\
1437 0 0 if $_is_MSWin32
1444 0 0 if $_is_MSWin32
1451 0 0 unless ref $self
1453 0 0 unless $self->{'_wid'}
1462 0 0 if defined $\
1463 0 0 if not $/ or $/ ne $MCE::LF
1465 0 0 if $_lock_chn
1469 0 0 if $_lock_chn
1483 0 0 unless ref $self
1489 0 0 if (defined $_abort_msg)
1492 0 0 if ($_abort_msg > 0)
1497 0 0 if ($self->{'_wid'} > 0)
1504 0 0 if $_lock_chn
1506 0 0 if $_lock_chn
1516 0 0 unless ref $self
1518 0 0 defined $_[0] ? :
1519 0 0 defined $_[1] ? :
1520 0 0 defined $_[2] ? :
1525 0 0 unless $self->{'_wid'}
1534 0 0 unless ($self->{'_exiting'})
1537 0 0 $self->{'_is_thread'} ? :
1541 0 0 if (defined $self->{'init_relay'} and not $self->{'_relayed'} and not $_task_id and exists $self->{'_wuf'} and $self->{'_pid'} eq $_pid)
1544 0 0 unless defined $self->{'_retry_cnt'}
1546 0 0 if (not $_max_retries or ++$self->{'_retry_cnt'} == $_max_retries)
1547 0 0 if $_chunk_id
1552 0 0 if $INC{'MCE/Child.pm'}
1555 0 0 if $INC{'MCE/Hobo.pm'} and "MCE::Hobo"->can("_clear")
1557 0 0 if defined $\
1561 0 0 if $_lock_chn
1563 0 0 if ($self->{'_retry'} and $self->{'_retry'}[2]--) { }
1581 0 0 if $_lock_chn
1590 0 0 unless ref $self
1591 0 0 if defined $self->{'_sess_dir'}
1593 0 0 if ($self->{'_wid'} == 0) { }
1595 0 0 $self->{'_spawned'} ? :
1605 0 0 if defined $\
1606 0 0 if not $/ or $/ ne $MCE::LF
1608 0 0 if $_lock_chn
1611 0 0 if $_lock_chn
1620 31 0 unless ref $self
1621 0 31 if defined $self->{'tmp_dir'}
1623 31 0 if ($self->{'_wid'} == 0) { }
1634 0 0 if defined $\
1635 0 0 if not $/ or $/ ne $MCE::LF
1637 0 0 if $_lock_chn
1640 0 0 if $_lock_chn
1655 130 3 unless ref $self
1656 0 133 caller() eq 'MCE' ? :
1658 0 133 if ref $_[0] eq "CODE"
1660 0 133 unless defined(my $_func = shift())
1663 133 0 if index($_func, ":") < 0
1665 133 0 if ($self->{'_wid'}) { }
1677 357 0 unless ref $self
1680 0 357 unless $self->{'_wid'}
1698 0 0 unless ref $self
1702 0 0 unless $self->{'_wid'}
1704 0 0 unless defined $_[0]
1707 0 0 exists $_sendto_lkup{lc $_to} ? :
1710 0 0 unless (defined $_dest)
1713 0 0 if (ref $_to and defined($_fd = fileno $_to) || defined($_fd = eval { do { $_to->fileno } })) { }
0 0 elsif (&reftype($_to) eq 'GLOB') { }
1716 0 0 if (my $_ob = tied *{$_to;})
1717 0 0 if (ref $_ob eq "IO::TieCombine::Handle")
1718 0 0 if lc $_ob->{'slot_name'} eq "stdout"
1719 0 0 if lc $_ob->{'slot_name'} eq "stderr"
1723 0 0 scalar @_ == 1 ? :
1730 0 0 if (defined $_to and $_to =~ /$_v2_regx/o)
1732 0 0 exists $_sendto_lkup{lc $1} ? :
1736 0 0 if (not defined $_dest or not defined $_value and $_dest == 1 || $_dest == 4)
1753 0 0 if ($_dest == 0)
1754 0 0 if not defined $_[1] or @_ > 2
1770 0 0 unless ref $self
1773 0 0 if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { }
0 0 elsif (&reftype($_[0]) eq 'GLOB') { }
1776 0 0 if (my $_ob = tied *{$_[0];})
1777 0 0 if (ref $_ob eq "IO::TieCombine::Handle")
1778 0 0 if lc $_ob->{'slot_name'} eq "stdout"
1779 0 0 if lc $_ob->{'slot_name'} eq "stderr"
1789 0 0 scalar @_ ? :
1791 0 0 if $_fd
1792 0 0 if $self->{'_wid'}
1797 0 0 unless ref $self
1800 0 0 if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { }
0 0 elsif (&reftype($_[0]) eq 'GLOB') { }
1803 0 0 if (my $_ob = tied *{$_[0];})
1804 0 0 if (ref $_ob eq "IO::TieCombine::Handle")
1805 0 0 if lc $_ob->{'slot_name'} eq "stdout"
1806 0 0 if lc $_ob->{'slot_name'} eq "stderr"
1817 0 0 scalar @_ ? :
1819 0 0 if $_fd
1820 0 0 if $self->{'_wid'}
1825 0 0 unless ref $self
1828 0 0 if (ref $_[0] and defined($_fd = fileno $_[0]) || defined($_fd = eval { do { $_[0]->fileno } })) { }
0 0 elsif (&reftype($_[0]) eq 'GLOB') { }
1831 0 0 if (my $_ob = tied *{$_[0];})
1832 0 0 if (ref $_ob eq "IO::TieCombine::Handle")
1833 0 0 if lc $_ob->{'slot_name'} eq "stdout"
1834 0 0 if lc $_ob->{'slot_name'} eq "stderr"
1844 0 0 scalar @_ ? :
1846 0 0 if $_fd
1847 0 0 if $self->{'_wid'}
1859 0 65 exists $self->{'_guard'} && $self->{'_guard'}[0] ? :
1861 0 65 if $_has_guard
1865 65 0 unless $_tid
1868 0 65 if $self->{'use_threads'}
1870 65 0 unless ($_tid)
1874 0 0 if $_[0] eq 'INT' || $_[0] eq 'TERM' and $^O ne "MSWin32"
1881 0 0 if ($self->{'posix_exit'} and not $_has_guard and not $_is_MSWin32)
1883 0 0 if $INC{'POSIX.pm'}
1891 0 126 unless ref $self
1893 91 35 if (defined $self->{'user_tasks'})
1894 91 0 if (defined $self->{'user_tasks'}[0]{'max_workers'})
1903 0 0 unless ref $self
1907 0 0 unless (defined $_sess_dir)
1909 0 0 unless defined $self->{'tmp_dir'}
1911 0 0 $INC{'threads.pm'} ? :
1912 0 0 unless defined $self->{'_mce_tid'}
1917 0 0 if not defined $_tmp_dir or $_tmp_dir eq ""
1919 0 0 unless -d $_tmp_dir
1921 0 0 unless -w $_tmp_dir
1949 0 5 if (length $_chop_str) { }
1970 0 187 if (defined $_params_ref->{'init_relay'} and not defined $self->{'init_relay'})
1974 0 561 if (defined $_params_ref->{$_p})
1981 0 311 unless exists $_params_allowed_args{$_p}
1986 81 106 $self->{'_spawned'} ? :
2005 0 0 if $_is_MSWin32 and defined $self->{'max_retries'} || $INC{'MCE/Child.pm'} || $INC{'MCE/Hobo.pm'}
2011 0 65 $_is_thread ? :
2023 65 0 unless ($self->{'use_threads'})
2025 0 65 if $INC{'Math/Prime/Util.pm'}
2028 0 65 if $INC{'MCE/Hobo.pm'} and "MCE::Hobo"->can("_clear")
2030 0 65 if $INC{'MCE/Child.pm'}
2034 0 65 if (not $self->{'use_threads'} and $INC{'Math/Random.pm'})
2037 0 0 $_cur_seed < 1073741781 ? :
2044 0 65 if (not $self->{'use_threads'} and $INC{'Math/Random/MT/Auto.pm'})
2048 0 0 $_cur_seed < 1073741781 ? :
2071 0 0 unless defined $_thr
2075 0 0 if (defined $_params)
2076 0 0 unless (defined $self->{'_tids'}[$_i])
2087 0 0 if defined $self->{'spawn_delay'} and $self->{'spawn_delay'} > 0
2098 0 277 unless defined $_pid
2101 65 212 if $_pid == 0
2105 0 212 if (defined $_params)
2106 0 0 unless (defined $self->{'_pids'}[$_i])
2114 0 212 if ($self->{'loop_timeout'} and not $_is_MSWin32)
2120 0 212 if defined $self->{'spawn_delay'} and $self->{'spawn_delay'} > 0