Shared/Server.pm

filter: Statementstmt 45.6% 480 / 1051 Branchbran 27.6% 193 / 698 Conditioncond 12.8% 36 / 280 MC/DCmcdc 2.4% 4 / 164 Subroutinesub 60.9% 81 / 133 Podpod n/a totaltotal 34.1% 794 / 2326 SCAR 109.5
CC
453
Cov
35%
export
1406.0
_loop
552.0
_share
462.0
CRAP 56956.1
↑ Summary Shared/Minidb.pm »
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Server/Object packages for MCE::Shared.
4 ##
5 ###############################################################################
6  
7 43 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 43 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 43 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 43 ▶no warnings qw( threads recursion uninitialized numeric once );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 package MCE::Shared::Server;
15  
16 43 our $VERSION = '1.886';
17  
18 ## no critic (BuiltinFunctions::ProhibitStringyEval)
19 ## no critic (Subroutines::ProhibitExplicitReturnUndef)
20 ## no critic (TestingAndDebugging::ProhibitNoStrict)
21 ## no critic (InputOutput::ProhibitTwoArgOpen)
22  
23 43 ▶use if $^O eq 'MSWin32', 'threads';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 43 ▶use if $^O eq 'MSWin32', 'threads::shared';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 43 ▶no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 43 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29 43 ▶use Storable ();
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 43 my ($_spawn_child, $_freeze, $_thaw);
32  
33 BEGIN {
34 43 ▶ local $@;
Subroutine BEGIN: called CC=8 SCAR=22.2
35  
36 eval 'use IO::FDPass ();'
37 43 ▶ if ( ! $INC{'IO/FDPass.pm'} && $^O !~ /cygwin|android/ );
Subroutine BEGIN: called CC=1 SCAR=0.4
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"IO/FDPass.pm"} or $^O =~ /cygwin|android/ 43 0 43
Condition33%1/3
$INC{"IO/FDPass.pm"} or $^O =~ /cygwin|android/
l!l&&r!l&&!r
0043
MC/DC0%0/2
$INC{"IO/FDPass.pm"} or $^O =~ /cygwin|android/
$INC{"IO/FDPass.pm"} $^O =~ /cygwin|android/
Truth table33%1/3
A or B
A= $INC{"IO/FDPass.pm"}B= $^O =~ /cygwin|android/
ABresult
1X1
011
000
38  
39 43 ▶ $_spawn_child = $INC{'threads.pm'} ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$INC{'threads.pm'} ? : 0 43 43
40  
41 43 ▶ if ( ! $INC{'PDL.pm'} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($INC{"PDL.pm"}) 43 0 43
42 43 ▶ 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
43 43 ▶ if ( ! $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 43 0 43
44 43 my $_encoder_ver = int( Sereal::Encoder->VERSION() );
45 43 my $_decoder_ver = int( Sereal::Decoder->VERSION() );
46 43 ▶ if ( $_encoder_ver - $_decoder_ver == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_encoder_ver - $_decoder_ver == 0) 43 0 43
47 43 $_freeze = \&Sereal::Encoder::encode_sereal;
48 43 $_thaw = \&Sereal::Decoder::decode_sereal;
49 }
50 }
51 }
52  
53 43 ▶ if ( ! defined $_freeze ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_freeze) 0 43 43
54 0 $_freeze = \&Storable::freeze;
55 0 $_thaw = \&Storable::thaw;
56 }
57 }
58  
59 0 ▶sub _get_freeze { $_freeze; }
Subroutine _get_freeze: not called CC=1 SCAR=6.9
60 0 ▶sub _get_thaw { $_thaw; }
Subroutine _get_thaw: not called CC=1 SCAR=6.9
61  
62 43 ▶use IO::Handle ();
Subroutine BEGIN: called CC=1 SCAR=0.0
63 43 ▶use Scalar::Util qw( blessed looks_like_number reftype weaken );
Subroutine BEGIN: called CC=1 SCAR=0.0
64 43 ▶use Socket qw( SOL_SOCKET SO_RCVBUF );
Subroutine BEGIN: called CC=1 SCAR=0.0
65 43 ▶use Time::HiRes qw( alarm sleep time );
Subroutine BEGIN: called CC=1 SCAR=0.0
66  
67 43 ▶use MCE::Signal 1.863 (); # requires 1.863 minimally
Subroutine BEGIN: called CC=1 SCAR=0.0
68 43 ▶use MCE::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
69 43 ▶use MCE::Mutex ();
Subroutine BEGIN: called CC=1 SCAR=0.0
70 43 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
71  
72 ## The POSIX module has many symbols. Try not loading it simply
73 ## to have WNOHANG. The following covers most platforms.
74  
75 use constant {
76 43 ▶ _WNOHANG => ( $INC{'POSIX.pm'} )
Branch: 2 branches
BranchTrueFalseTotal
$INC{'POSIX.pm'} ? : 0 43 43
$^O eq 'solaris' ? : 0 43 43
77 ? &POSIX::WNOHANG : ( $^O eq 'solaris' ) ? 64 : 1
78 43 ▶};
Subroutine BEGIN: called CC=3 SCAR=11.0
79  
80 use constant {
81 # Max data channels. This cannot be greater than 8 on MSWin32.
82 43 DATA_CHANNELS => 8,
83  
84 SHR_M_NEW => 'M~NEW', # New share
85 SHR_M_CID => 'M~CID', # ClientID request
86 SHR_M_DEE => 'M~DEE', # Deeply shared
87 SHR_M_INC => 'M~INC', # Increment count
88 SHR_M_OBJ => 'M~OBJ', # Object request
89 SHR_M_OB0 => 'M~OB0', # Object request - thaw'less
90 SHR_M_DES => 'M~DES', # Destroy request
91 SHR_M_EXP => 'M~EXP', # Export request
92 SHR_M_INX => 'M~INX', # Iterator next
93 SHR_M_IRW => 'M~IRW', # Iterator rewind
94 SHR_M_STP => 'M~STP', # Exit loop
95  
96 SHR_O_PDL => 'O~PDL', # PDL::ins inplace(this),what,coords
97 SHR_O_DAT => 'O~DAT', # Get MCE::Hobo data
98 SHR_O_CLR => 'O~CLR', # Clear
99 SHR_O_FCH => 'O~FCH', # Fetch
100 SHR_O_SZE => 'O~SZE', # Size
101  
102 WA_ARRAY => 1, # Wants list
103 43 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
104  
105 ###############################################################################
106 ## ----------------------------------------------------------------------------
107 ## Private functions.
108 ##
109 ###############################################################################
110  
111 43 my ($_SVR, $_stopped, %_all, %_obj, %_ob2, %_ob3, %_itr, %_new) = (undef);
112 43 my ($_next_id, $_is_client, $_init_pid, $_svr_pid) = (0, 1);
113 43 my $LF = "\012"; Internals::SvREADONLY($LF, 1);
114 43 my %_export_nul;
115  
116 43 my @_db_modules = qw(
117 AnyDBM_File DB_File GDBM_File NDBM_File ODBM_File SDBM_File
118 BerkeleyDB::Btree BerkeleyDB::Hash BerkeleyDB::Queue
119 BerkeleyDB::Recno CDB_File KyotoCabinet::DB SQLite_File
120 TokyoCabinet::ADB TokyoCabinet::BDB TokyoCabinet::HDB
121 Tie::Array::DBD Tie::Hash::DBD
122 );
123  
124 43 ▶my $_is_MSWin32 = ( $^O eq 'MSWin32') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 43 43
125 43 ▶my $_tid = $INC{'threads.pm'} ? threads->tid() : 0;
Branch: 1 branch
BranchTrueFalseTotal
$INC{'threads.pm'} ? : 0 43 43
126 43 my $_oid = "$$.$_tid";
127  
128 sub _croak {
129 0 ▶ Carp::carp($_[0]);
Subroutine _croak: not called CC=1 SCAR=6.9
130 0 MCE::Signal::stop_and_exit('INT');
131 }
132 sub CLONE {
133 0 ▶ $_tid = threads->tid() if $INC{'threads.pm'};
Subroutine CLONE: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"threads.pm"} 0 0 0
134 }
135  
136 END {
137 43 ▶ CORE::kill('KILL', $$)
Subroutine END: called CC=6 SCAR=19.9
Branch: 1 branch
BranchTrueFalseTotal
if $_is_MSWin32 and $MCE::Signal::KILLED 0 43 43
Condition33%1/3
$_is_MSWin32 and $MCE::Signal::KILLED
!ll&&!rl&&r
4300
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
138 if ($_is_MSWin32 && $MCE::Signal::KILLED);
139 43 ▶ &_stop()
Branch: 1 branch
BranchTrueFalseTotal
if $_init_pid and $_init_pid eq "${$}.$_tid" and $_is_client 15 28 43
Condition66%4/6
$_init_pid and $_init_pid eq "${$}.$_tid" and $_is_client
!ll&&!rl&&r
28015
$_init_pid and $_init_pid eq "${$}.$_tid"
!ll&&!rl&&r
02815
MC/DC33%1/3
$_init_pid and $_init_pid eq "${$}.$_tid" and $_is_client
$_init_pid $_init_pid eq "${$}.$_tid" $_is_client
Truth table50%2/4
A and B and C
A= $_init_pidB= $_init_pid eq "${$}.$_tid"C= $_is_client
ABCresult
0XX0
10X0
1100
1111
140 if ($_init_pid && $_init_pid eq "$$.$_tid" && $_is_client);
141 }
142  
143 sub _new {
144 158 ▶ my ($_class, $_deeply, %_hndls) = ($_[0]->{class}, $_[0]->{_DEEPLY_});
Subroutine _new: called CC=21 SCAR=30.9
145 158 my $_has_fh = ($_class =~ /^MCE::Shared::(?:Condvar|Queue)$/);
146  
147 158 ▶ if (!$_svr_pid) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_svr_pid) 31 127 158
148 # Minimum support on platforms without IO::FDPass (not installed).
149 # Condvar and Queue must be shared first before others.
150 $_export_nul{ $_class } = undef, return _share(@_)
151 31 ▶ if $_has_fh && !$INC{'IO/FDPass.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $_has_fh and not $INC{"IO/FDPass.pm"} 0 31 31
Condition66%2/3
$_has_fh and not $INC{"IO/FDPass.pm"}
!ll&&!rl&&r
20110
MC/DC0%0/2
$_has_fh and not $INC{"IO/FDPass.pm"}
$_has_fh not $INC{"IO/FDPass.pm"}
Truth table66%2/3
A and not(B)
A= $_has_fhB= not $INC{"IO/FDPass.pm"}
ABresult
0X0
100
111
152  
153 31 _start();
154 }
155  
156 158 ▶ if ($_has_fh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_fh) 29 129 158
157 _croak("Sharing module '$_class' while the server is running\n".
158 "requires the 'IO::FDPass' module, missing in Perl")
159 29 ▶ if !$INC{'IO/FDPass.pm'};
Branch: 1 branch
BranchTrueFalseTotal
unless $INC{"IO/FDPass.pm"} 0 29 29
160  
161 29 for my $_k (qw(
162 _qr_mutex _qw_sock _qr_sock _aw_sock _ar_sock _cw_sock _cr_sock
163 )) {
164 203 ▶ if ( defined $_[1]->{ $_k } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[1]{$_k}) 84 119 203
165 84 $_hndls{ $_k } = delete $_[1]->{ $_k };
166 84 $_[1]->{ $_k } = undef;
167 }
168 }
169 }
170  
171 158 my $_chn = $_SVR->{_data_channels} + 1;
172 158 my $_DAT_LOCK = $_SVR->{'_mutex_'.$_chn};
173 158 my $_DAT_W_SOCK = $_SVR->{_dat_w_sock}[0];
174 158 my $_DAU_W_SOCK = $_SVR->{_dat_w_sock}[$_chn];
175  
176 ##
177 # Sereal cannot encode $DB_RECNO. Therefore, must encode using Storable.
178 # Error: DB_File::RECNOINFO does not define the method FIRSTKEY
179 #
180 # my $ob = tie my @db, 'MCE::Shared', { module => 'DB_File' }, $file,
181 # O_RDWR|O_CREAT, 0640, $DB_RECNO or die "open error '$file': $!";
182 ##
183  
184 158 my $_buf = Storable::freeze(shift);
185 158 my $_bu2 = Storable::freeze([ @_ ]);
186  
187 158 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 158 158
188 158 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 158 158
189  
190 158 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_DAT_LOCK->lock();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 158 158
191  
192 158 print({$_DAT_W_SOCK} SHR_M_NEW.$LF . $_chn.$LF),
193 158 ▶ print({$_DAU_W_SOCK} length($_buf).$LF, $_buf, length($_bu2).$LF, $_bu2,
Branch: 1 branch
BranchTrueFalseTotal
keys %_hndls ? : 29 129 158
194 (keys %_hndls ? 1 : 0).$LF);
195  
196 158 <$_DAU_W_SOCK>;
197  
198 158 undef($_buf), undef($_bu2);
199  
200 158 ▶ if (keys %_hndls) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %_hndls) 29 129 158
201 29 for my $_k (qw( _qw_sock _qr_sock _aw_sock _cw_sock )) {
202 116 ▶ if (exists $_hndls{ $_k }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_hndls{$_k}) 55 61 116
203 55 IO::FDPass::send( fileno $_DAU_W_SOCK, fileno $_hndls{ $_k } );
204 55 <$_DAU_W_SOCK>;
205 }
206 }
207 }
208  
209 158 chomp(my $_id = <$_DAU_W_SOCK>),
210 chomp(my $_len = <$_DAU_W_SOCK>);
211  
212 158 ▶ read($_DAU_W_SOCK, $_buf, $_len) if $_len;
Branch: 1 branch
BranchTrueFalseTotal
if $_len 158 0 158
213  
214 158 ▶ $_DAT_LOCK->unlock() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 158 0 158
215  
216 158 ▶ $! = $_id, return '' unless $_len;
Branch: 1 branch
BranchTrueFalseTotal
unless $_len 0 158 158
217  
218 158 ▶ if (keys %_hndls) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %_hndls) 29 129 158
219 29 $_all{ $_id } = $_class;
220 29 $_obj{ $_id } = \%_hndls;
221 }
222  
223 158 ▶ if (!$_deeply) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_deeply) 156 2 158
224 # for auto-destroy
225 156 ▶ $_new{ $_id } = $_tid ? $$ .'.'. $_tid : $$;
Branch: 1 branch
BranchTrueFalseTotal
$_tid ? : 0 156 156
226 }
227  
228 158 return $_thaw->($_buf);
229 }
230  
231 sub _incr_count {
232 0 ▶ return unless $_svr_pid;
Subroutine _incr_count: not called CC=7 SCAR=40.3
Branch: 1 branch
BranchTrueFalseTotal
unless $_svr_pid 0 0 0
233  
234 0 my $_chn = $_SVR->{_data_channels} + 1;
235 0 my $_DAT_LOCK = $_SVR->{'_mutex_'.$_chn};
236 0 my $_DAT_W_SOCK = $_SVR->{_dat_w_sock}[0];
237 0 my $_DAU_W_SOCK = $_SVR->{_dat_w_sock}[$_chn];
238  
239 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
240 0 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 0 0
241 0 local $MCE::Signal::SIG;
242  
243 {
244 0 local $MCE::Signal::IPC = 1;
245 0 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_DAT_LOCK->lock();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 0 0
246  
247 0 print({$_DAT_W_SOCK} SHR_M_INC.$LF . $_chn.$LF),
248 0 print({$_DAU_W_SOCK} $_[0].$LF);
249 0 <$_DAU_W_SOCK>;
250  
251 0 ▶ $_DAT_LOCK->unlock() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 0 0 0
252 }
253  
254 0 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 0 0
255  
256 0 return;
257 }
258  
259 sub _share {
260 0 ▶ my ($_params, $_item) = (shift, shift);
Subroutine _share: not called CC=21 SCAR=61.4
261 0 my $_class = delete $_params->{'class'};
262 0 my $_id = ++$_next_id;
263  
264 0 ▶ if ($_class eq ':construct_module:') {
Branch: 2 branches
BranchTrueFalseTotal
if ($_class eq ':construct_module:') { } 0 0 0
elsif ($_class eq ':construct_pdl:') { } 0 0 0
265 0 my ($_module, $_fcn) = ($_params->{module}, pop @{ $_item });
266 0 ▶ my $_has_args = @{ $_item } ? 1 : 0; local $@;
Branch: 1 branch
BranchTrueFalseTotal
@{$_item;} ? : 0 0 0
267  
268 0 ($_module) = $_module =~ /(.*)/; # remove tainted'ness
269 0 ($_fcn ) = $_fcn =~ /(.*)/;
270  
271 0 ▶ MCE::Shared::_use( $_class = $_module ) or _croak("$@\n");
Branch: 1 branch
BranchTrueFalseTotal
MCE::Shared::_use($_class = $_module) or _croak("$@\n") 0 0 0
272  
273 0 ▶ _croak("Can't locate object method \"$_fcn\" via package \"$_module\"")
Branch: 1 branch
BranchTrueFalseTotal
unless eval " $_module->can('${_fcn}') " 0 0 0
274 unless eval qq{ $_module->can('$_fcn') };
275  
276 0 ▶ $! = 0; $_item = $_module->$_fcn(@{ $_item }) or return '';
Branch: 1 branch
BranchTrueFalseTotal
$_item = $_module->$_fcn(@{$_item;}) or return "" 0 0 0
277  
278 0 ▶ $_export_nul{ $_class } = undef if ($_class->isa('Graphics::Framebuffer'));
Branch: 1 branch
BranchTrueFalseTotal
if $_class->isa("Graphics::Framebuffer") 0 0 0
279 0 ▶ $_export_nul{ $_class } = undef if ($_fcn eq 'TIEHANDLE');
Branch: 1 branch
BranchTrueFalseTotal
if $_fcn eq "TIEHANDLE" 0 0 0
280  
281 0 ▶ return '' if (
Branch: 1 branch
BranchTrueFalseTotal
if $_has_args and $_fcn eq "TIEHANDLE" and not defined fileno $_item 0 0 0
Condition0%0/6
$_has_args and $_fcn eq "TIEHANDLE" and not defined fileno $_item
!ll&&!rl&&r
000
$_has_args and $_fcn eq "TIEHANDLE"
!ll&&!rl&&r
000
MC/DC0%0/3
$_has_args and $_fcn eq "TIEHANDLE" and not defined fileno $_item
$_has_args $_fcn eq "TIEHANDLE" not defined fileno $_item
Truth table0%0/4
A and B and not(C)
A= $_has_argsB= $_fcn eq "TIEHANDLE"C= not defined fileno $_item
ABCresult
0XX0
10X0
1100
1111
282 $_has_args && $_fcn eq 'TIEHANDLE' && !defined(fileno $_item)
283 );
284 }
285 elsif ($_class eq ':construct_pdl:') {
286 0 local $@; local $SIG{__DIE__};
287  
288 0 $_class = 'PDL', $_item = eval q{
289 unless ($INC{'PDL.pm'}) {
290 use PDL;
291 # Disable PDL auto-threading.
292 eval q{ PDL::set_autopthread_targ(1) };
293 }
294  
295 my $_func = pop @{ $_item };
296  
297 if ($_func eq 'sbyte' ) { sbyte (@{ $_item }); }
298 elsif ($_func eq 'byte' ) { byte (@{ $_item }); }
299 elsif ($_func eq 'short' ) { short (@{ $_item }); }
300 elsif ($_func eq 'ushort' ) { ushort (@{ $_item }); }
301 elsif ($_func eq 'long' ) { long (@{ $_item }); }
302 elsif ($_func eq 'ulong' ) { ulong (@{ $_item }); }
303 elsif ($_func eq 'indx' ) { indx (@{ $_item }); }
304 elsif ($_func eq 'longlong' ) { longlong (@{ $_item }); }
305 elsif ($_func eq 'ulonglong') { ulonglong (@{ $_item }); }
306 elsif ($_func eq 'float' ) { float (@{ $_item }); }
307 elsif ($_func eq 'double' ) { double (@{ $_item }); }
308 elsif ($_func eq 'ldouble' ) { ldouble (@{ $_item }); }
309 elsif ($_func eq 'sequence' ) { sequence (@{ $_item }); }
310 elsif ($_func eq 'zeroes' ) { zeroes (@{ $_item }); }
311 elsif ($_func eq 'zeros' ) { zeros (@{ $_item }); }
312 elsif ($_func eq 'ones' ) { ones (@{ $_item }); }
313 elsif ($_func eq 'random' ) { random (@{ $_item }); }
314 elsif ($_func eq 'grandom' ) { grandom (@{ $_item }); }
315 else { pdl (@{ $_item }); }
316 };
317 }
318  
319 0 $_all{ $_id } = $_class;
320 0 $_ob3{"$_id:count"} = 1;
321  
322 0 ▶ if ($_class eq 'MCE::Shared::Handle' && reftype $_item eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_class eq 'MCE::Shared::Handle' and builtin::reftype($_item) eq 'ARRAY') { } 0 0 0
Condition0%0/3
$_class eq "MCE::Shared::Handle" and builtin::reftype($_item) eq "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/2
$_class eq "MCE::Shared::Handle" and builtin::reftype($_item) eq "ARRAY"
$_class eq "MCE::Shared::Handle" builtin::reftype($_item) eq "ARRAY"
Truth table0%0/3
A and B
A= $_class eq "MCE::Shared::Handle"B= builtin::reftype($_item) eq "ARRAY"
ABresult
0X0
100
111
323 0 $_obj{ $_id } = IO::Handle->new();
324 0 $_export_nul{ $_class } = undef;
325  
326 0 bless $_obj{ $_id }, $_class;
327 }
328 else {
329 0 $_obj{ $_id } = $_item;
330  
331 0 ▶ if ( reftype $_obj{ $_id } eq 'HASH' &&
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($_obj{$_id}) eq "HASH" and builtin::reftype($_obj{$_id}{"fh"}) eq "GLOB") 0 0 0
Condition0%0/3
builtin::reftype($_obj{$_id}) eq "HASH" and builtin::reftype($_obj{$_id}{"fh"}) eq "GLOB"
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::reftype($_obj{$_id}) eq "HASH" and builtin::reftype($_obj{$_id}{"fh"}) eq "GLOB"
builtin::reftype($_obj{$_id}) eq "HASH" builtin::reftype($_obj{$_id}{"fh"}) eq "GLOB"
Truth table0%0/3
A and B
A= builtin::reftype($_obj{$_id}) eq "HASH"B= builtin::reftype($_obj{$_id}{"fh"}) eq "GLOB"
ABresult
0X0
100
111
332 reftype $_obj{ $_id }->{'fh'} eq 'GLOB' ) {
333  
334 0 ▶ if ( $_class->isa('Tie::File') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_class->isa("Tie::File")) 0 0 0
335 # enable autoflush, enable raw layer
336 0 $_obj{ $_id }->{'fh'}->autoflush(1);
337 0 binmode($_obj{ $_id }->{'fh'}, ':raw');
338 }
339  
340 0 $_export_nul{ $_class } = undef;
341 }
342 }
343  
344 0 my $self = bless [ $_id, $_class ], 'MCE::Shared::Object';
345  
346 0 $_ob2{ $_id } = $_freeze->([ $self ]);
347  
348 0 ▶ if ( $_params->{tied} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_params->{"tied"}) 0 0 0
349 # set encoder/decoder upon receipt in MCE::Shared::_tie
350 0 for my $_module ( @_db_modules ) {
351 0 ▶ $self->[2] = 1, last if $_class->isa($_module);
Branch: 1 branch
BranchTrueFalseTotal
if $_class->isa($_module) 0 0 0
352 }
353 0 ▶ $_export_nul{ $_class } = undef if $self->[2];
Branch: 1 branch
BranchTrueFalseTotal
if $self->[2] 0 0 0
354 }
355  
356 0 return $self;
357 }
358  
359 sub _start {
360 91 ▶ return if $_svr_pid;
Subroutine _start: called CC=18 SCAR=38.9
Branch: 1 branch
BranchTrueFalseTotal
if $_svr_pid 48 43 91
361  
362 43 ▶ if ($INC{'PDL.pm'}) { local $@;
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{"PDL.pm"}) 0 43 43
363 # PDL::IO::Storable is required for serializing piddles.
364 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
365 # PDL data should not be naively copied in new threads.
366 0 eval 'no warnings; sub PDL::CLONE_SKIP { 1 }';
367 # Disable PDL auto-threading.
368 0 eval q{ PDL::set_autopthread_targ(1) };
369 }
370  
371 43 local $_; $_init_pid = "$$.$_tid", $_stopped = undef;
372  
373 43 ▶ my $_data_channels = ($_init_pid eq $_oid) ? DATA_CHANNELS : 2;
Branch: 1 branch
BranchTrueFalseTotal
$_init_pid eq $_oid ? : 43 0 43
374  
375 43 $_SVR = { _data_channels => $_data_channels };
376  
377 # Defaults to the misc channel used by _new, _get_hobo_data, and export.
378 43 MCE::Util::_sock_pair($_SVR, qw(_dat_r_sock _dat_w_sock), 0);
379 MCE::Util::_sock_pair($_SVR, qw(_dat_r_sock _dat_w_sock), $_, 1)
380 43 for (1 .. $_data_channels + 1);
381  
382 43 ▶ if ($^O !~ /linux|android|aix/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($^O =~ /linux|android|aix/) 0 43 43
383 0 setsockopt($_SVR->{_dat_r_sock}[0], SOL_SOCKET, SO_RCVBUF, 4096);
384 }
385  
386 43 ▶ if ($_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_MSWin32) { } 0 43 43
387 0 for (1 .. $_data_channels + 1) {
388 0 my $_mutex;
389 0 $_SVR->{'_mutex_'.$_} = threads::shared::share($_mutex);
390 }
391 }
392 else {
393 $_SVR->{'_mutex_'.$_} = MCE::Mutex->new( impl => 'Channel' )
394 43 for (1 .. $_data_channels + 1);
395 }
396  
397 43 MCE::Shared::Object::_start();
398  
399 local $SIG{TTIN}, local $SIG{TTOU}, local $SIG{WINCH}
400 43 ▶ unless $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 43 0 43
401  
402 43 ▶ if ($_spawn_child) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_spawn_child) { } 43 0 43
403 43 $_svr_pid = fork();
404 43 ▶ _loop() if (defined $_svr_pid && $_svr_pid == 0);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_svr_pid and $_svr_pid == 0 0 43 43
Condition33%1/3
defined $_svr_pid and $_svr_pid == 0
!ll&&!rl&&r
0430
MC/DC0%0/2
defined $_svr_pid and $_svr_pid == 0
defined $_svr_pid $_svr_pid == 0
Truth table33%1/3
A and B
A= defined $_svr_pidB= $_svr_pid == 0
ABresult
0X0
100
111
405 }
406 else {
407 0 $_svr_pid = threads->create(\&_loop);
408 0 ▶ $_svr_pid->detach() if defined $_svr_pid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_svr_pid 0 0 0
409 }
410  
411 43 ▶ _croak("cannot start the shared-manager process: $!")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_svr_pid 0 43 43
412 unless (defined $_svr_pid);
413  
414 43 ▶ sleep 0.015 if (!$_spawn_child || $_is_MSWin32);
Branch: 1 branch
BranchTrueFalseTotal
if not $_spawn_child or $_is_MSWin32 0 43 43
Condition33%1/3
not $_spawn_child or $_is_MSWin32
l!l&&r!l&&!r
0043
MC/DC0%0/2
not $_spawn_child or $_is_MSWin32
not $_spawn_child $_is_MSWin32
Truth table33%1/3
not(A) or B
A= not $_spawn_childB= $_is_MSWin32
ABresult
1X1
011
000
415  
416 43 return;
417 }
418  
419 sub _stop {
420 15 ▶ $_stopped = 1;
Subroutine _stop: called CC=12 SCAR=27.4
421 15 ▶ return unless ($_is_client && $_init_pid && $_init_pid eq "$$.$_tid");
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_client and $_init_pid and $_init_pid eq "${$}.$_tid" 0 15 15
Condition33%2/6
$_is_client and $_init_pid and $_init_pid eq "${$}.$_tid"
!ll&&!rl&&r
0015
$_is_client and $_init_pid
!ll&&!rl&&r
0015
MC/DC0%0/3
$_is_client and $_init_pid and $_init_pid eq "${$}.$_tid"
$_is_client $_init_pid $_init_pid eq "${$}.$_tid"
Truth table25%1/4
A and B and C
A= $_is_clientB= $_init_pidC= $_init_pid eq "${$}.$_tid"
ABCresult
0XX0
10X0
1100
1111
422  
423 15 ▶ MCE::Child->finish('MCE') if $INC{'MCE/Child.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Child.pm"} 0 15 15
424 15 ▶ MCE::Hobo->finish('MCE') if $INC{'MCE/Hobo.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Hobo.pm"} 3 12 15
425  
426 15 local ($!, $?, $@);
427  
428 15 ▶ if (defined $_svr_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_svr_pid) 15 0 15
429 15 my $_DAT_W_SOCK = $_SVR->{_dat_w_sock}[0];
430  
431 15 ▶ if (ref $_svr_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_svr_pid) { } 0 15 15
432 0 eval { $_svr_pid->kill('KILL') };
433 }
434 else {
435 local $SIG{HUP} = local $SIG{QUIT} = local $SIG{PIPE} =
436 15 ▶ local $SIG{INT} = local $SIG{TERM} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=0.0
437  
438 15 my $_start = time;
439  
440 15 eval {
441 15 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 15 15
442 15 print {$_DAT_W_SOCK} SHR_M_STP.$LF.'0'.$LF;
443 };
444  
445 15 while () {
446 30 ▶ last if waitpid($_svr_pid, _WNOHANG);
Branch: 1 branch
BranchTrueFalseTotal
if waitpid $_svr_pid, 1 15 15 30
447 15 ▶ if ( time - $_start > 0.7 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&MCE::Shared::Server::time() - $_start > "0.7") 0 15 15
448 0 CORE::kill('USR2', $_svr_pid);
449 0 waitpid($_svr_pid, 0);
450 0 last;
451 }
452 15 sleep 0.045;
453 }
454 }
455  
456 15 $_init_pid = $_svr_pid = undef;
457 15 %_all = (), %_obj = ();
458  
459 15 MCE::Util::_destroy_socks($_SVR, qw( _dat_w_sock _dat_r_sock ));
460  
461 15 for my $_i (1 .. $_SVR->{_data_channels} + 1) {
462 135 delete $_SVR->{'_mutex_'.$_i};
463 }
464  
465 15 MCE::Shared::Object::_stop();
466 }
467  
468 15 return;
469 }
470  
471 sub _pid {
472 0 ▶ return ref($_svr_pid) ? int($_init_pid) : $_svr_pid;
Subroutine _pid: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_svr_pid ? : 0 0 0
473 }
474  
475 sub _destroy {
476 0 ▶ my ($_lkup, $_item, $_id) = @_;
Subroutine _destroy: not called CC=19 SCAR=59.4
477  
478 # safety for circular references to not destroy dangerously
479 0 ▶ return if exists $_ob3{ "$_id:count" } && --$_ob3{ "$_id:count" } > 0;
Branch: 1 branch
BranchTrueFalseTotal
if exists $_ob3{"${_id}:count"} and --$_ob3{"${_id}:count"} > 0 0 0 0
Condition0%0/3
exists $_ob3{"${_id}:count"} and --$_ob3{"${_id}:count"} > 0
!ll&&!rl&&r
000
MC/DC0%0/2
exists $_ob3{"${_id}:count"} and --$_ob3{"${_id}:count"} > 0
exists $_ob3{"${_id}:count"} --$_ob3{"${_id}:count"} > 0
Truth table0%0/3
A and B
A= exists $_ob3{"${_id}:count"}B= --$_ob3{"${_id}:count"} > 0
ABresult
0X0
100
111
480  
481 # safety for circular references to not loop endlessly
482 0 ▶ return if exists $_lkup->{ $_id };
Branch: 1 branch
BranchTrueFalseTotal
if exists $_lkup->{$_id} 0 0 0
483  
484 0 $_lkup->{ $_id } = undef;
485  
486 0 ▶ if (exists $_ob3{ "$_id:deeply" }) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $_ob3{"${_id}:deeply"}) { } 0 0 0
elsif (exists $_obj{$_id}) { } 0 0 0
487 0 for my $_oid (keys %{ $_ob3{ "$_id:deeply" } }) {
488 0 _destroy($_lkup, $_obj{ $_oid }, $_oid);
489 }
490 0 delete $_ob3{ "$_id:deeply" };
491 }
492 elsif (exists $_obj{ $_id }) {
493 0 ▶ if ($_obj{ $_id }->isa('MCE::Shared::Scalar') ||
Branch: 7 branches
BranchTrueFalseTotal
if ($_obj{$_id}->isa('MCE::Shared::Scalar') or $_obj{$_id}->isa('Tie::StdScalar')) { } 0 0 0
elsif ($_obj{$_id}->isa('Tie::File')) { } 0 0 0
elsif ($_obj{$_id}->can('sync')) { } 0 0 0
elsif ($_obj{$_id}->can('db_sync')) { } 0 0 0
elsif ($_obj{$_id}->can('close')) { } 0 0 0
elsif ($_obj{$_id}->can('DESTROY')) { } 0 0 0
elsif (builtin::reftype($_obj{$_id}) eq 'GLOB') { } 0 0 0
Condition0%0/3
$_obj{$_id}->isa("MCE::Shared::Scalar") or $_obj{$_id}->isa("Tie::StdScalar")
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id}->isa("MCE::Shared::Scalar") or $_obj{$_id}->isa("Tie::StdScalar")
$_obj{$_id}->isa("MCE::Shared::Scalar") $_obj{$_id}->isa("Tie::StdScalar")
Truth table0%0/3
A or B
A= $_obj{$_id}->isa("MCE::Shared::Scalar")B= $_obj{$_id}->isa("Tie::StdScalar")
ABresult
1X1
011
000
494 $_obj{ $_id }->isa('Tie::StdScalar')) {
495  
496 0 ▶ if (blessed($_item->FETCH())) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($_item->FETCH)) 0 0 0
497 0 my $_oid = $_item->FETCH()->SHARED_ID();
498 0 _destroy($_lkup, $_obj{ $_oid }, $_oid);
499 }
500  
501 0 undef ${ $_obj{ $_id } };
502 }
503 0 elsif ($_obj{ $_id }->isa('Tie::File')) { $_obj{ $_id }->flush(); }
504 0 elsif ($_obj{ $_id }->can('sync')) { $_obj{ $_id }->sync(); }
505 0 elsif ($_obj{ $_id }->can('db_sync')) { $_obj{ $_id }->db_sync(); }
506 0 elsif ($_obj{ $_id }->can('close')) { $_obj{ $_id }->close(); }
507 0 elsif ($_obj{ $_id }->can('DESTROY')) { delete $_obj{ $_id }; }
508 elsif (reftype $_obj{ $_id } eq 'GLOB') {
509 0 ▶ close $_obj{ $_id } if defined(fileno $_obj{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_obj{$_id} 0 0 0
510 }
511 }
512  
513 0 ▶ weaken( delete $_obj{ $_id } ) if exists($_obj{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if exists $_obj{$_id} 0 0 0
514 0 ▶ weaken( delete $_itr{ $_id } ) if exists($_itr{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if exists $_itr{$_id} 0 0 0
515  
516 delete($_itr{ "$_id:args" }), delete($_all{ $_id }),
517 0 delete($_ob3{ "$_id:count" }), delete($_ob2{ $_id });
518  
519 0 return;
520 }
521  
522 ###############################################################################
523 ## ----------------------------------------------------------------------------
524 ## Server loop.
525 ##
526 ###############################################################################
527  
528 sub _exit {
529 0 ▶ $SIG{__DIE__} = sub {} unless $_tid;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Subroutine _exit: not called CC=19 SCAR=59.4
Branch: 1 branch
BranchTrueFalseTotal
unless $_tid 0 0 0
530 0 ▶ $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
531  
532 # Flush file handles.
533 0 for my $_id ( keys %_obj ) {
534 0 eval {
535 0 ▶ if ($_obj{ $_id }->isa('Tie::File')) { $_obj{ $_id }->flush(); }
Branch: 6 branches
BranchTrueFalseTotal
if ($_obj{$_id}->isa('Tie::File')) { } 0 0 0
elsif ($_obj{$_id}->can('sync')) { } 0 0 0
elsif ($_obj{$_id}->can('db_sync')) { } 0 0 0
elsif ($_obj{$_id}->can('close')) { } 0 0 0
elsif ($_obj{$_id}->can('DESTROY')) { } 0 0 0
elsif (builtin::reftype($_obj{$_id}) eq 'GLOB') { } 0 0 0
536 0 elsif ($_obj{ $_id }->can('sync')) { $_obj{ $_id }->sync(); }
537 0 elsif ($_obj{ $_id }->can('db_sync')) { $_obj{ $_id }->db_sync(); }
538 0 elsif ($_obj{ $_id }->can('close')) { $_obj{ $_id }->close(); }
539 0 elsif ($_obj{ $_id }->can('DESTROY')) { delete $_obj{ $_id }; }
540 elsif (reftype $_obj{ $_id } eq 'GLOB') {
541 0 ▶ close $_obj{ $_id } if defined(fileno $_obj{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_obj{$_id} 0 0 0
542 }
543 };
544 }
545  
546 # Destroy non-exportable objects.
547 0 for my $_id ( keys %_all ) {
548 0 eval {
549 weaken( delete $_obj{ $_id } )
550 0 ▶ if ( exists $_export_nul{ $_all{ $_id } } );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_export_nul{$_all{$_id}} 0 0 0
551 };
552 }
553  
554 # Wait for the main thread to exit.
555 0 ▶ if ( !$_spawn_child && ($_is_MSWin32 || $INC{'Tk.pm'} || $INC{'Wx.pm'}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $_spawn_child and $_is_MSWin32 || $INC{"Tk.pm"} || $INC{"Wx.pm"}) 0 0 0
Condition0%0/9
not $_spawn_child and $_is_MSWin32 || $INC{"Tk.pm"} || $INC{"Wx.pm"}
!ll&&!rl&&r
000
$_is_MSWin32 or $INC{"Tk.pm"} or $INC{"Wx.pm"}
l!l&&r!l&&!r
000
$_is_MSWin32 or $INC{"Tk.pm"}
l!l&&r!l&&!r
000
MC/DC0%0/4
not $_spawn_child and $_is_MSWin32 || $INC{"Tk.pm"} || $INC{"Wx.pm"}
not $_spawn_child $_is_MSWin32 $INC{"Tk.pm"} $INC{"Wx.pm"}
Truth table0%0/5
not(A) and B or C or D
A= not $_spawn_childB= $_is_MSWin32C= $INC{"Tk.pm"}D= $INC{"Wx.pm"}
ABCDresult
0XXX0
10000
11XX1
101X1
10011
556 0 sleep 1.0;
557 }
558  
559 0 ▶ threads->exit(0) if ( !$_spawn_child || $_is_MSWin32 );
Branch: 1 branch
BranchTrueFalseTotal
if not $_spawn_child or $_is_MSWin32 0 0 0
Condition0%0/3
not $_spawn_child or $_is_MSWin32
l!l&&r!l&&!r
000
MC/DC0%0/2
not $_spawn_child or $_is_MSWin32
not $_spawn_child $_is_MSWin32
Truth table0%0/3
not(A) or B
A= not $_spawn_childB= $_is_MSWin32
ABresult
1X1
011
000
560  
561 0 ▶ CORE::kill('KILL', $$) unless $_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 0 0 0
562 0 CORE::exit(0);
563 }
564  
565 sub _loop {
566 0 ▶ $_is_client = 0;
Subroutine _loop: not called CC=23 SCAR=63.1
567  
568 0 ▶ $MCE::MCE = undef if ($MCE::MCE && $MCE::MCE->{_wid} == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::MCE and $MCE::MCE->{"_wid"} == 0 0 0 0
Condition0%0/3
$MCE::MCE and $MCE::MCE->{"_wid"} == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$MCE::MCE and $MCE::MCE->{"_wid"} == 0
$MCE::MCE $MCE::MCE->{"_wid"} == 0
Truth table0%0/3
A and B
A= $MCE::MCEB= $MCE::MCE->{"_wid"} == 0
ABresult
0X0
100
111
569  
570 0 local $\ = undef; local $/ = $LF; $| = 1;
571 0 my $_running_inside_eval = $^S;
572  
573 ▶ local $SIG{TERM} = local $SIG{QUIT} = local $SIG{INT} = local $SIG{HUP} = sub {}
Subroutine __ANON__: not called CC=1 SCAR=0.0
574 0 ▶ if ($_init_pid eq $_oid);
Branch: 1 branch
BranchTrueFalseTotal
if $_init_pid eq $_oid 0 0 0
575  
576 0 ▶ local $SIG{PIPE} = sub { $SIG{PIPE} = sub {}; CORE::kill('PIPE', getppid()); }
Subroutine __ANON__: not called CC=1 SCAR=6.9
577 0 ▶ if ($_spawn_child && !$_is_MSWin32);
Branch: 1 branch
BranchTrueFalseTotal
if $_spawn_child and not $_is_MSWin32 0 0 0
Condition0%0/3
$_spawn_child and not $_is_MSWin32
!ll&&!rl&&r
000
MC/DC0%0/2
$_spawn_child and not $_is_MSWin32
$_spawn_child not $_is_MSWin32
Truth table0%0/3
A and not(B)
A= $_spawn_childB= not $_is_MSWin32
ABresult
0X0
100
111
578  
579 0 ▶ local $SIG{USR2} = \&_exit if ($_init_pid eq $_oid && !$_is_MSWin32);
Branch: 1 branch
BranchTrueFalseTotal
if $_init_pid eq $_oid and not $_is_MSWin32 0 0 0
Condition0%0/3
$_init_pid eq $_oid and not $_is_MSWin32
!ll&&!rl&&r
000
MC/DC0%0/2
$_init_pid eq $_oid and not $_is_MSWin32
$_init_pid eq $_oid not $_is_MSWin32
Truth table0%0/3
A and not(B)
A= $_init_pid eq $_oidB= not $_is_MSWin32
ABresult
0X0
100
111
580 0 ▶ local $SIG{KILL} = \&_exit if ($_init_pid eq $_oid && !$_spawn_child);
Branch: 1 branch
BranchTrueFalseTotal
if $_init_pid eq $_oid and not $_spawn_child 0 0 0
Condition0%0/3
$_init_pid eq $_oid and not $_spawn_child
!ll&&!rl&&r
000
MC/DC0%0/2
$_init_pid eq $_oid and not $_spawn_child
$_init_pid eq $_oid not $_spawn_child
Truth table0%0/3
A and not(B)
A= $_init_pid eq $_oidB= not $_spawn_child
ABresult
0X0
100
111
581  
582 local $SIG{__DIE__} = sub {
583 0 ▶ if (!defined $^S || $^S) {
Subroutine __ANON__: not called CC=12 SCAR=50.5
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $^S or $^S) 0 0 0
Condition0%0/3
not defined $^S or $^S
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $^S or $^S
not defined $^S $^S
Truth table0%0/3
not(A) or B
A= not defined $^SB= $^S
ABresult
1X1
011
000
584 0 ▶ if ( ($INC{'threads.pm'} && threads->tid() != 0) ||
Branch: 1 branch
BranchTrueFalseTotal
if ($INC{'threads.pm'} and 'threads'->tid != 0 or $ENV{'PERL_IPERL_RUNNING'} or $_running_inside_eval) { } 0 0 0
Condition0%0/9
$INC{"threads.pm"} and "threads"->tid != 0 or $ENV{"PERL_IPERL_RUNNING"} or $_running_inside_eval
l!l&&r!l&&!r
000
$INC{"threads.pm"} and "threads"->tid != 0 or $ENV{"PERL_IPERL_RUNNING"}
l!l&&r!l&&!r
000
$INC{"threads.pm"} and "threads"->tid != 0
!ll&&!rl&&r
000
MC/DC0%0/4
$INC{"threads.pm"} and "threads"->tid != 0 or $ENV{"PERL_IPERL_RUNNING"} or $_running_inside_eval
$INC{"threads.pm"} "threads"->tid != 0 $ENV{"PERL_IPERL_RUNNING"} $_running_inside_eval
Truth table0%0/7
A and B or C or D
A= $INC{"threads.pm"}B= "threads"->tid != 0C= $ENV{"PERL_IPERL_RUNNING"}D= $_running_inside_eval
ABCDresult
11XX1
0X1X1
101X1
0X011
10011
0X000
10000
585 $ENV{'PERL_IPERL_RUNNING'} ||
586 $_running_inside_eval
587 ) {
588 # thread env or running inside IPerl, check stack trace
589 0 my $_t = Carp::longmess(); $_t =~ s/\teval [^\n]+\n$//;
590 0 ▶ CORE::die(@_)
Branch: 1 branch
BranchTrueFalseTotal
if $_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ 0 0 0
Condition0%0/3
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/
l!l&&r!l&&!r
000
MC/DC0%0/2
$_t =~ /^(?:[^\n]+\n){1,7}\teval / or $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/
$_t =~ /^(?:[^\n]+\n){1,7}\teval / $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/
Truth table0%0/3
A or B
A= $_t =~ /^(?:[^\n]+\n){1,7}\teval /B= $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/
ABresult
1X1
011
000
591 if ( $_t =~ /^(?:[^\n]+\n){1,7}\teval / ||
592 $_t =~ /\n\teval [^\n]+\n\t(?:eval|Try)/ );
593 }
594 else {
595 # normal env, trust $^S
596 0 CORE::die(@_);
597 }
598 }
599  
600 0 ▶ $SIG{INT} = $SIG{__DIE__} = $SIG{__WARN__} = sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
601 0 ▶ print {*STDERR} defined $_[0] ? $_[0] : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] ? : 0 0 0
602  
603 0 ▶ ( $_spawn_child && !$_is_MSWin32 )
Branch: 1 branch
BranchTrueFalseTotal
$_spawn_child && !$_is_MSWin32 ? : 0 0 0
Condition0%0/3
$_spawn_child and not $_is_MSWin32
!ll&&!rl&&r
000
MC/DC0%0/2
$_spawn_child and not $_is_MSWin32
$_spawn_child not $_is_MSWin32
Truth table0%0/3
A and not(B)
A= $_spawn_childB= not $_is_MSWin32
ABresult
0X0
100
111
604 ? CORE::kill('KILL', -getpgrp)
605 : CORE::exit($?);
606 0 };
607  
608 0 my ($_id, $_fcn, $_wa, $_len, $_func, $_var);
609 0 my ($_channel_id, $_done) = (0, 0);
610  
611 0 my $_channels = $_SVR->{_dat_r_sock};
612 0 my $_DAT_R_SOCK = $_SVR->{_dat_r_sock}[0];
613 0 my $_DAU_R_SOCK;
614  
615 my $_auto_reply = sub {
616 0 ▶ if ( $_wa == WA_ARRAY ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($_wa == 1) 0 0 0
617 0 my @_ret = eval { $_var->$_fcn(@_) };
618 0 my $_buf = $_freeze->(\@_ret);
619 0 return print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
620 }
621  
622 0 my $_ret = eval { $_var->$_fcn(@_) };
623 0 my $_buf = $_freeze->([ $_ret ]);
624  
625 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
626 0 };
627  
628 my $_obj_keys = sub {
629 0 ▶ my ( $_obj, @_keys, $_cnt ) = ( shift );
Subroutine __ANON__: not called CC=11 SCAR=48.8
630  
631 0 ▶ return keys %{ $_obj } if $_obj->isa('Tie::StdHash');
Branch: 1 branch
BranchTrueFalseTotal
if $_obj->isa("Tie::StdHash") 0 0 0
632 0 ▶ return (0 .. $_obj->FETCHSIZE - 1) unless $_obj->can('FIRSTKEY');
Branch: 1 branch
BranchTrueFalseTotal
unless $_obj->can("FIRSTKEY") 0 0 0
633  
634 0 ▶ if ( wantarray ) {
Branch: 3 branches
BranchTrueFalseTotal
if (wantarray) { } 0 0 0
elsif ($_obj->isa('Tie::ExtraHash')) { } 0 0 0
elsif ($_obj->isa('Tie::IxHash')) { } 0 0 0
635 0 my $_key = $_obj->FIRSTKEY;
636 0 ▶ if ( defined $_key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_key) 0 0 0
637 0 push @_keys, $_key;
638 # CDB_File expects the $_key argument
639 0 ▶ while ( defined( $_key = $_obj->NEXTKEY($_key) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_key = $_obj->NEXTKEY($_key))) 0 0 0
640 0 push @_keys, $_key;
641 }
642 }
643 }
644 elsif ( $_obj->isa('Tie::ExtraHash') ) {
645 0 $_cnt = keys %{ $_obj->[0] };
646 }
647 elsif ( $_obj->isa('Tie::IxHash') ) {
648 0 $_cnt = keys %{ $_obj->[2] };
649 }
650 else {
651 0 my $_key = $_obj->FIRSTKEY; $_cnt = 0;
652 0 ▶ if ( defined $_key ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_key) 0 0 0
653 0 $_cnt = 1;
654 # CDB_File expects the $_key argument
655 0 ▶ while ( defined( $_key = $_obj->NEXTKEY($_key) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_key = $_obj->NEXTKEY($_key))) 0 0 0
656 0 $_cnt++;
657 }
658 }
659 }
660  
661 0 ▶ wantarray ? @_keys : $_cnt;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
662 0 };
663  
664 my $_iter = sub {
665 0 ▶ unless ( exists $_itr{ $_id } ) {
Subroutine __ANON__: not called CC=16 SCAR=56.1
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_itr{$_id}) 0 0 0
666  
667 0 my $pkg = $_all{ $_id };
668 0 ▶ my $flg = ($pkg->can('NEXTKEY') || $pkg->can('keys')) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$pkg->can('NEXTKEY') || $pkg->can('keys') ? : 0 0 0
Condition0%0/3
$pkg->can("NEXTKEY") or $pkg->can("keys")
l!l&&r!l&&!r
000
MC/DC0%0/2
$pkg->can("NEXTKEY") or $pkg->can("keys")
$pkg->can("NEXTKEY") $pkg->can("keys")
Truth table0%0/3
A or B
A= $pkg->can("NEXTKEY")B= $pkg->can("keys")
ABresult
1X1
011
000
669 0 ▶ my $get = $pkg->can('FETCH') ? 'FETCH' : $pkg->can('get') ? 'get' : '';
Branch: 2 branches
BranchTrueFalseTotal
$pkg->can('FETCH') ? : 0 0 0
$pkg->can('get') ? : 0 0 0
670  
671 0 ▶ unless ( ($flg || $pkg->can('FETCHSIZE')) && $get ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($flg || $pkg->can("FETCHSIZE") and $get) 0 0 0
Condition0%0/6
$flg || $pkg->can("FETCHSIZE") and $get
!ll&&!rl&&r
000
$flg or $pkg->can("FETCHSIZE")
l!l&&r!l&&!r
000
MC/DC0%0/3
$flg || $pkg->can("FETCHSIZE") and $get
$flg $pkg->can("FETCHSIZE") $get
Truth table0%0/5
A or B and C
A= $flgB= $pkg->can("FETCHSIZE")C= $get
ABCresult
00X0
1X00
0100
1X11
0111
672 0 print {$_DAU_R_SOCK} '-1'.$LF;
673 0 return;
674 }
675  
676 # MCE::Shared::{ Array, Cache, Hash, Ordhash }, Hash::Ordered,
677 # or similar module.
678  
679 0 ▶ $get = 'peek' if $pkg->isa('MCE::Shared::Cache');
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->isa("MCE::Shared::Cache") 0 0 0
680  
681 0 ▶ if ( !exists $_itr{ "$_id:args" } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $_itr{"${_id}:args"}) { } 0 0 0
682 0 @{ $_itr{ "$_id:args" } } = $pkg->can('keys')
683 ? $_obj{ $_id }->keys()
684 0 ▶ : $_obj_keys->( $_obj{ $_id } );
Branch: 1 branch
BranchTrueFalseTotal
$pkg->can('keys') ? : 0 0 0
685 }
686 else {
687 0 my $_args = $_itr{ "$_id:args" };
688 0 ▶ if ( @{ $_args } == 1 &&
Branch: 1 branch
BranchTrueFalseTotal
if (@{$_args;} == 1 and $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/) { } 0 0 0
Condition0%0/3
@{$_args;} == 1 and $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
!ll&&!rl&&r
000
MC/DC0%0/2
@{$_args;} == 1 and $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
@{$_args;} == 1 $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
Truth table0%0/3
A and B
A= @{$_args;} == 1B= $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
ABresult
0X0
100
111
689 $_args->[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/ ) {
690  
691 0 ▶ @{ $_args } = $_obj{ $_id }->keys($_args->[0])
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->isa("MCE::Shared::Common") 0 0 0
692 if $pkg->isa('MCE::Shared::Common');
693 }
694 else {
695 0 ▶ $_obj{ $_id }->_prune_head()
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->isa("MCE::Shared::Cache") 0 0 0
696 if $pkg->isa('MCE::Shared::Cache');
697 }
698 }
699  
700 $_itr{ $_id } = sub {
701 0 ▶ my $_key = shift @{ $_itr{ "$_id:args" } };
Subroutine __ANON__: not called CC=2 SCAR=17.9
702 0 ▶ print({$_DAU_R_SOCK} '-1'.$LF), return if !defined($_key);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_key 0 0 0
703 0 my $_buf = $_freeze->([ $_key, $_obj{ $_id }->$get($_key) ]);
704 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
705 0 };
706 }
707  
708 0 $_itr{ $_id }->();
709  
710 0 return;
711 0 };
712  
713 my $_warn = sub {
714 0 ▶ if ( $_wa ) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if ($_wa) 0 0 0
715 0 my $_buf = $_freeze->([ ]);
716 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
717 }
718 0 };
719  
720 # --------------------------------------------------------------------------
721  
722 0 my %_output_function; %_output_function = (
723  
724 SHR_M_NEW.$LF => sub { # New share
725 0 ▶ my ($_buf, $_params, $_class, $_args, $_fd, $_item);
Subroutine __ANON__: not called CC=14 SCAR=53.5
726  
727 0 chomp($_len = <$_DAU_R_SOCK>),
728 read($_DAU_R_SOCK, $_buf, $_len);
729  
730 0 $_params = Storable::thaw($_buf);
731 0 $_class = $_params->{'class'};
732  
733 0 ▶ { local $@; MCE::Shared::_use($_params->{module} || $_class); }
Condition0%0/3
$_params->{'module'} || $_class
l!l&&r!l&&!r
000
MC/DC0%0/2
$_params->{'module'} || $_class
$_params->{'module'} $_class
Truth table0%0/3
A || B
A= $_params->{'module'}B= $_class
ABresult
1X1
011
000
734  
735 chomp($_len = <$_DAU_R_SOCK>), read($_DAU_R_SOCK, $_buf, $_len),
736 0 chomp($_len = <$_DAU_R_SOCK>), print({$_DAU_R_SOCK} $LF);
737  
738 0 $_args = Storable::thaw($_buf); undef $_buf;
739  
740 0 ▶ if ($_len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len) 0 0 0
741 0 $_export_nul{ $_class } = undef;
742  
743 0 for my $_k (qw( _qw_sock _qr_sock _aw_sock _cw_sock )) {
744 0 ▶ if (exists $_args->[0]->{ $_k }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_args->[0]{$_k}) 0 0 0
745 0 delete $_args->[0]->{ $_k };
746  
747 0 ▶ $_fd = IO::FDPass::recv(fileno $_DAU_R_SOCK); $_fd >= 0
Branch: 1 branch
BranchTrueFalseTotal
$_fd >= 0 or _croak("cannot receive file handle: $!") 0 0 0
748 or _croak("cannot receive file handle: $!");
749  
750 0 ▶ open $_args->[0]->{ $_k }, "+<&=$_fd"
Branch: 1 branch
BranchTrueFalseTotal
open $_args->[0]{$_k}, "+<&=$_fd" or _croak("cannot convert file discriptor to handle: $!") 0 0 0
751 or _croak("cannot convert file discriptor to handle: $!");
752  
753 0 print {$_DAU_R_SOCK} $LF;
754 }
755 }
756 }
757  
758 0 ▶ $_item = _share($_params, @{ $_args }) or do {
Branch: 1 branch
BranchTrueFalseTotal
$_item = _share($_params, @{$_args;}) or do { print {$_DAU_R_SOCK;} int($!) . $LF . '0' . $LF; return } 0 0 0
759 0 print {$_DAU_R_SOCK} int($!).$LF . '0'.$LF;
760 0 return;
761 };
762  
763 0 $_buf = $_freeze->($_item);
764  
765 0 print {$_DAU_R_SOCK} $_item->SHARED_ID().$LF .
766 length($_buf).$LF, $_buf;
767  
768 0 ▶ if ($_class eq 'MCE::Shared::Queue') {
Branch: 3 branches
BranchTrueFalseTotal
if ($_class eq 'MCE::Shared::Queue') { } 0 0 0
elsif (builtin::reftype($_obj{$_item->[0]}) eq 'GLOB') { } 0 0 0
elsif ($_class eq 'MCE::Shared::Condvar') { } 0 0 0
769 MCE::Shared::Queue::_init_mgr(
770 \$_DAU_R_SOCK, \%_obj, \%_output_function, $_freeze, $_thaw
771 0 ▶ ) if $INC{'MCE/Shared/Queue.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Queue.pm"} 0 0 0
772 }
773 elsif (reftype $_obj{ $_item->[0] } eq 'GLOB') {
774 MCE::Shared::Handle::_init_mgr(
775 \$_DAU_R_SOCK, \%_obj, \%_output_function, $_freeze, $_thaw
776 0 ▶ ) if $INC{'MCE/Shared/Handle.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Handle.pm"} 0 0 0
777 }
778 elsif ($_class eq 'MCE::Shared::Condvar') {
779 MCE::Shared::Condvar::_init_mgr(
780 \$_DAU_R_SOCK, \%_obj, \%_output_function
781 0 ▶ ) if $INC{'MCE/Shared/Condvar.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Condvar.pm"} 0 0 0
782 }
783  
784 0 return;
785 },
786  
787 SHR_M_CID.$LF => sub { # ClientID request
788 0 ▶ print {$_DAU_R_SOCK} (++$_channel_id).$LF;
Subroutine __ANON__: not called CC=2 SCAR=17.9
789 0 ▶ $_channel_id = 0 if ($_channel_id >= $_SVR->{_data_channels});
Branch: 1 branch
BranchTrueFalseTotal
if $_channel_id >= $_SVR->{"_data_channels"} 0 0 0
790  
791 0 return;
792 },
793  
794 SHR_M_DEE.$LF => sub { # Deeply shared
795 0 ▶ chomp(my $_id1 = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=1 SCAR=6.9
796 chomp(my $_id2 = <$_DAU_R_SOCK>);
797  
798 0 $_ob3{ "$_id1:deeply" }->{ $_id2 } = undef;
799  
800 0 return;
801 },
802  
803 SHR_M_INC.$LF => sub { # Increment count
804 0 ▶ chomp($_id = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=1 SCAR=6.9
805  
806 0 $_ob3{ "$_id:count" }++;
807 0 print {$_DAU_R_SOCK} $LF;
808  
809 0 return;
810 },
811  
812 SHR_M_OBJ.$LF => sub { # Object request
813 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=4 SCAR=30.0
814 chomp($_fcn = <$_DAU_R_SOCK>),
815 chomp($_wa = <$_DAU_R_SOCK>),
816 chomp($_len = <$_DAU_R_SOCK>),
817  
818 read($_DAU_R_SOCK, my($_buf), $_len);
819  
820 0 ▶ $_var = $_obj{ $_id } || do { return $_warn->($_fcn) };
Condition0%0/3
$_obj{$_id} || do { return &$_warn($_fcn) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id} || do { return &$_warn($_fcn) }
$_obj{$_id} do { return &$_warn($_fcn) }
Truth table0%0/3
A || B
A= $_obj{$_id}B= do { return &$_warn($_fcn) }
ABresult
1X1
011
000
821  
822 0 $_wa ? $_auto_reply->(@{ $_thaw->($_buf) })
823 0 ▶ : eval { $_var->$_fcn(@{ $_thaw->($_buf) }) };
Branch: 1 branch
BranchTrueFalseTotal
$_wa ? : 0 0 0
824  
825 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
826 0 return;
827 },
828  
829 SHR_M_OB0.$LF => sub { # Object request - thaw'less
830 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=12 SCAR=50.5
831 chomp($_fcn = <$_DAU_R_SOCK>),
832 chomp($_wa = <$_DAU_R_SOCK>);
833  
834 0 ▶ $_var = $_obj{ $_id } || do { return $_warn->($_fcn) };
Condition0%0/3
$_obj{$_id} || do { return &$_warn($_fcn) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id} || do { return &$_warn($_fcn) }
$_obj{$_id} do { return &$_warn($_fcn) }
Truth table0%0/3
A || B
A= $_obj{$_id}B= do { return &$_warn($_fcn) }
ABresult
1X1
011
000
835  
836 0 ▶ my $_code = $_var->can($_fcn) || do {
Condition0%0/3
$_var->can($_fcn) || do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_wa ? &$_auto_reply() : eval { do { $_var->$_fcn } }; warn $@ if $@; return; } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_var->can($_fcn) || do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_wa ? &$_auto_reply() : eval { do { $_var->$_fcn } }; warn $@ if $@; return; } }
$_var->can($_fcn) do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_wa ? &$_auto_reply() : eval { do { $_var->$_fcn } }; warn $@ if $@; return; } }
Truth table0%0/3
A || B
A= $_var->can($_fcn)B= do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_wa ? &$_auto_reply() : eval { do { $_var->$_fcn } }; warn $@ if $@; return; } }
ABresult
1X1
011
000
837 0 ▶ if ( ($_fcn eq 'keys' || $_fcn eq 'SCALAR') &&
Branch: 1 branch
BranchTrueFalseTotal
if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { } 0 0 0
Condition0%0/9
$_fcn eq "keys" || $_fcn eq "SCALAR" and $_var->can("NEXTKEY") || $_var->can("FETCHSIZE")
!ll&&!rl&&r
000
$_fcn eq "keys" or $_fcn eq "SCALAR"
l!l&&r!l&&!r
000
$_var->can("NEXTKEY") or $_var->can("FETCHSIZE")
l!l&&r!l&&!r
000
MC/DC0%0/4
$_fcn eq "keys" || $_fcn eq "SCALAR" and $_var->can("NEXTKEY") || $_var->can("FETCHSIZE")
$_fcn eq "keys" $_fcn eq "SCALAR" $_var->can("NEXTKEY") $_var->can("FETCHSIZE")
Truth table0%0/7
A or B and C or D
A= $_fcn eq "keys"B= $_fcn eq "SCALAR"C= $_var->can("NEXTKEY")D= $_var->can("FETCHSIZE")
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
838 ($_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) ) {
839 0 $_obj_keys;
840 }
841 else {
842 0 ▶ $_wa ? $_auto_reply->() : eval { $_var->$_fcn() };
Branch: 1 branch
BranchTrueFalseTotal
$_wa ? : 0 0 0
843 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
844 0 return;
845 }
846 };
847  
848 0 ▶ if ( $_wa == WA_ARRAY ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_wa == 1) { } 0 0 0
elsif ($_wa) { } 0 0 0
849 0 my @_ret = eval { $_code->($_var) };
850 0 my $_buf = $_freeze->(\@_ret);
851 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
852 }
853 elsif ( $_wa ) {
854 0 my $_ret = eval { $_code->($_var) };
855 0 my $_buf = $_freeze->([ $_ret ]);
856 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
857 }
858 else {
859 0 eval { $_code->($_var) };
860 }
861  
862 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
863 0 return;
864 },
865  
866 SHR_M_DES.$LF => sub { # Destroy request
867 0 ▶ chomp($_id = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=3 SCAR=24.8
868  
869 0 local $SIG{__DIE__};
870 0 local $SIG{__WARN__};
871  
872 0 $_var = undef; local $@;
873  
874 0 eval {
875 0 ▶ my $_ret = exists($_all{ $_id }) ? '1' : '0';
Branch: 1 branch
BranchTrueFalseTotal
exists $_all{$_id} ? : 0 0 0
876 0 ▶ _destroy({}, $_obj{ $_id }, $_id) if $_ret;
Branch: 1 branch
BranchTrueFalseTotal
if $_ret 0 0 0
877 };
878  
879 0 print {$_DAU_R_SOCK} $LF;
880  
881 0 return;
882 },
883  
884 SHR_M_EXP.$LF => sub { # Export request
885 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=6 SCAR=37.4
886 chomp($_len = <$_DAU_R_SOCK>);
887  
888 0 ▶ read($_DAU_R_SOCK, my($_keys), $_len) if $_len;
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
889  
890 0 ▶ if (exists $_obj{ $_id }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_obj{$_id}) { } 0 0 0
891 0 my $_buf;
892  
893 # Do not export: e.g. objects with file handles
894 0 ▶ if ( exists $_export_nul{ $_all{ $_id } } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_export_nul{$_all{$_id}}) 0 0 0
895 0 print {$_DAU_R_SOCK} '-1'.$LF;
896 0 return;
897 }
898  
899 # MCE::Shared::{ Array, Hash, Ordhash }, Hash::Ordered
900 0 ▶ if ($_obj{ $_id }->can('clone')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_obj{$_id}->can('clone')) { } 0 0 0
901 $_buf = ($_len)
902 0 ? Storable::freeze($_obj{ $_id }->clone(@{ $_thaw->($_keys) }))
903 0 ▶ : Storable::freeze($_obj{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
$_len ? : 0 0 0
904 }
905 # Other
906 else {
907 0 $_buf = Storable::freeze($_obj{ $_id });
908 }
909  
910 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
911 0 undef $_buf;
912 }
913 else {
914 0 print {$_DAU_R_SOCK} '-1'.$LF;
915 }
916  
917 0 return;
918 },
919  
920 SHR_M_INX.$LF => sub { # Iterator next
921 0 ▶ chomp($_id = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=2 SCAR=17.9
922  
923 0 my $_var = $_obj{ $_id };
924  
925 0 ▶ if ( my $_code = $_var->can('next') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_code = $_var->can('next')) { } 0 0 0
926 0 my $_buf = $_freeze->([ $_code->($_var) ]);
927 0 print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
928 }
929 else {
930 0 $_iter->();
931 }
932  
933 0 return;
934 },
935  
936 SHR_M_IRW.$LF => sub { # Iterator rewind
937 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=4 SCAR=30.0
938 chomp($_len = <$_DAU_R_SOCK>),
939  
940 read($_DAU_R_SOCK, my($_buf), $_len);
941  
942 0 my $_var = $_obj{ $_id };
943  
944 0 ▶ if ( my $_code = $_var->can('rewind') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_code = $_var->can('rewind')) { } 0 0 0
945 0 $_code->($_var, @{ $_thaw->($_buf) });
946 }
947 else {
948 0 ▶ weaken( delete $_itr{ $_id } ) if ( exists $_itr{ $_id } );
Branch: 1 branch
BranchTrueFalseTotal
if exists $_itr{$_id} 0 0 0
949 0 my @_args = @{ $_thaw->($_buf) };
950 0 ▶ if ( @_args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_args) { } 0 0 0
951 0 $_itr{ "$_id:args" } = \@_args;
952 } else {
953 0 delete $_itr{ "$_id:args" };
954 }
955 }
956  
957 0 print {$_DAU_R_SOCK} $LF;
958  
959 0 return;
960 },
961  
962 SHR_M_STP.$LF => sub { # Exit loop
963 0 ▶ $SIG{USR2} = sub {} unless $_is_MSWin32;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 0 0 0
964  
965 0 $_done = 1;
966  
967 0 return;
968 },
969  
970 SHR_O_PDL.$LF => sub { # PDL::ins inplace(this),...
971 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=11 SCAR=48.8
972 chomp($_len = <$_DAU_R_SOCK>),
973  
974 read($_DAU_R_SOCK, my($_buf), $_len);
975  
976 0 ▶ if ($_all{ $_id } eq 'PDL') {
Branch: 1 branch
BranchTrueFalseTotal
if ($_all{$_id} eq "PDL") 0 0 0
977 # PDL ins( inplace($this), $what, @coords );
978 0 local @_ = @{ Storable::thaw($_buf) };
979  
980 0 ▶ if (@_ == 1) {
Branch: 5 branches
BranchTrueFalseTotal
if (@_ == 1) { } 0 0 0
elsif (@_ == 2 and $_[0] =~ /^:,(\d+):(\d+)/ and ref $_[1]) { } 0 0 0
elsif (not ref $_[0] and $_[0] =~ /^(\d+)$/) { } 0 0 0
elsif (@_ == 2) { } 0 0 0
elsif (@_ > 2) { } 0 0 0
981 0 ins( inplace($_obj{ $_id }), @_, 0, 0 );
982 }
983 ▶ elsif (@_ == 2 && $_[0] =~ /^:,(\d+):(\d+)/ && ref($_[1])) {
Condition0%0/6
@_ == 2 and $_[0] =~ /^:,(\d+):(\d+)/ and ref $_[1]
!ll&&!rl&&r
000
@_ == 2 and $_[0] =~ /^:,(\d+):(\d+)/
!ll&&!rl&&r
000
MC/DC0%0/3
@_ == 2 and $_[0] =~ /^:,(\d+):(\d+)/ and ref $_[1]
@_ == 2 $_[0] =~ /^:,(\d+):(\d+)/ ref $_[1]
Truth table0%0/4
A and B and C
A= @_ == 2B= $_[0] =~ /^:,(\d+):(\d+)/C= ref $_[1]
ABCresult
0XX0
10X0
1100
1111
984 0 my $_s = $2 - $1;
985 0 ins( inplace($_obj{ $_id }), $_[1]->slice(":,0:$_s"), 0, $1 );
986 }
987 ▶ elsif (!ref($_[0]) && $_[0] =~ /^(\d+)$/) {
Condition0%0/3
not ref $_[0] and $_[0] =~ /^(\d+)$/
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $_[0] and $_[0] =~ /^(\d+)$/
not ref $_[0] $_[0] =~ /^(\d+)$/
Truth table0%0/3
not(A) and B
A= not ref $_[0]B= $_[0] =~ /^(\d+)$/
ABresult
0X0
100
111
988 0 $_obj{ $_id }->set(@_);
989 }
990 elsif (@_ == 2) {
991 0 $_[0] =~ /^:,(\d+)/;
992 0 ▶ ins( inplace($_obj{ $_id }), $_[1], 0, $1 // $_[0] );
Condition0%0/3
$1 // $_[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 // $_[0]
$1 $_[0]
Truth table0%0/3
A // B
A= $1B= $_[0]
ABresult
1X1
011
000
993 }
994 elsif (@_ > 2) {
995 0 ins( inplace($_obj{ $_id }), @_ );
996 }
997 }
998  
999 0 return;
1000 },
1001  
1002 SHR_O_DAT.$LF => sub { # Get MCE::Hobo data
1003 0 ▶ my $_key;
Subroutine __ANON__: not called CC=3 SCAR=24.8
1004  
1005 0 chomp($_id = <$_DAU_R_SOCK>),
1006 chomp($_key = <$_DAU_R_SOCK>);
1007  
1008 0 ▶ my $error = delete $_obj{ $_id }{ 'S'.$_key } // '';
Condition0%0/2
delete $_obj{$_id}{'S' . $_key} // ""
l!l
00
MC/DC0%0/1
delete $_obj{$_id}{'S' . $_key} // ""
delete $_obj{$_id}{'S' . $_key}
Truth table0%0/2
A
A= delete $_obj{$_id}{'S' . $_key}
Aresult
11
00
1009 0 ▶ my $result = delete $_obj{ $_id }{ 'R'.$_key } // '';
Condition0%0/2
delete $_obj{$_id}{'R' . $_key} // ""
l!l
00
MC/DC0%0/1
delete $_obj{$_id}{'R' . $_key} // ""
delete $_obj{$_id}{'R' . $_key}
Truth table0%0/2
A
A= delete $_obj{$_id}{'R' . $_key}
Aresult
11
00
1010  
1011 0 print {$_DAU_R_SOCK}
1012 length($error).$LF . length($result).$LF . $error, $result;
1013  
1014 0 return;
1015 },
1016  
1017 SHR_O_CLR.$LF => sub { # Clear
1018 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=5 SCAR=34.0
1019 chomp($_fcn = <$_DAU_R_SOCK>);
1020  
1021 0 ▶ my $_var = $_obj{ $_id } || do { return };
Condition0%0/3
$_obj{$_id} || do { return }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id} || do { return }
$_obj{$_id} do { return }
Truth table0%0/3
A || B
A= $_obj{$_id}B= do { return }
ABresult
1X1
011
000
1022  
1023 0 ▶ if (exists $_ob3{ "$_id:deeply" }) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_ob3{"${_id}:deeply"}) 0 0 0
1024 0 my $_keep = { $_id => 1 };
1025 0 for my $_oid (keys %{ $_ob3{ "$_id:deeply" } }) {
1026 0 _destroy($_keep, $_obj{ $_oid }, $_oid);
1027 }
1028 0 delete $_ob3{ "$_id:deeply" };
1029 }
1030  
1031 0 eval { $_var->$_fcn() };
1032  
1033 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1034 0 return;
1035 },
1036  
1037 SHR_O_FCH.$LF => sub { # Fetch
1038 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=10 SCAR=47.0
1039 chomp($_fcn = <$_DAU_R_SOCK>),
1040 chomp($_len = <$_DAU_R_SOCK>);
1041  
1042 0 ▶ read($_DAU_R_SOCK, my($_key), $_len) if $_len;
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
1043  
1044 0 ▶ my $_var = $_obj{ $_id } || do {
Condition0%0/3
$_obj{$_id} || do { return print({$_DAU_R_SOCK;} '-1' . $LF) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id} || do { return print({$_DAU_R_SOCK;} '-1' . $LF) }
$_obj{$_id} do { return print({$_DAU_R_SOCK;} '-1' . $LF) }
Truth table0%0/3
A || B
A= $_obj{$_id}B= do { return print({$_DAU_R_SOCK;} '-1' . $LF) }
ABresult
1X1
011
000
1045 0 return print {$_DAU_R_SOCK} '-1'.$LF;
1046 };
1047  
1048 my $_buf = $_len
1049 0 ▶ ? eval { $_var->$_fcn( chop $_key ? ${ $_thaw->($_key) } : $_key ) }
Branch: 1 branch
BranchTrueFalseTotal
chop $_key ? : 0 0 0
1050 0 ▶ : eval { $_var->$_fcn() };
Branch: 1 branch
BranchTrueFalseTotal
$_len ? : 0 0 0
1051  
1052 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1053  
1054 0 ▶ return print {$_DAU_R_SOCK} '-1'.$LF if ( !defined $_buf );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_buf 0 0 0
1055  
1056 my $_ret = ( blessed($_buf) && $_buf->can('SHARED_ID') && $_ob2{ $_buf->[0] } )
1057 0 ▶ ? $_ob2{ $_buf->[0] }
Branch: 1 branch
BranchTrueFalseTotal
builtin::blessed($_buf) && $_buf->can('SHARED_ID') && $_ob2{$_buf->[0]} ? : 0 0 0
Condition0%0/6
builtin::blessed($_buf) and $_buf->can("SHARED_ID") and $_ob2{$_buf->[0]}
!ll&&!rl&&r
000
builtin::blessed($_buf) and $_buf->can("SHARED_ID")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($_buf) and $_buf->can("SHARED_ID") and $_ob2{$_buf->[0]}
builtin::blessed($_buf) $_buf->can("SHARED_ID") $_ob2{$_buf->[0]}
Truth table0%0/4
A and B and C
A= builtin::blessed($_buf)B= $_buf->can("SHARED_ID")C= $_ob2{$_buf->[0]}
ABCresult
0XX0
10X0
1100
1111
1058 : $_freeze->([ $_buf ]);
1059  
1060 0 print {$_DAU_R_SOCK} length($_ret).$LF, $_ret;
1061  
1062 0 return;
1063 },
1064  
1065 SHR_O_SZE.$LF => sub { # Size
1066 0 ▶ chomp($_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: not called CC=10 SCAR=47.0
1067 chomp($_fcn = <$_DAU_R_SOCK>);
1068  
1069 0 ▶ $_var = $_obj{ $_id } || do {
Condition0%0/3
$_obj{$_id} || do { print {$_DAU_R_SOCK;} $LF if $_wa; return }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_obj{$_id} || do { print {$_DAU_R_SOCK;} $LF if $_wa; return }
$_obj{$_id} do { print {$_DAU_R_SOCK;} $LF if $_wa; return }
Truth table0%0/3
A || B
A= $_obj{$_id}B= do { print {$_DAU_R_SOCK;} $LF if $_wa; return }
ABresult
1X1
011
000
1070 0 ▶ print {$_DAU_R_SOCK} $LF if $_wa;
Branch: 1 branch
BranchTrueFalseTotal
if $_wa 0 0 0
1071 0 return;
1072 };
1073  
1074 0 ▶ my $_code = $_var->can($_fcn) || do {
Condition0%0/3
$_var->can($_fcn) || do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_len = eval { do { $_var->$_fcn } }; print {$_DAU_R_SOCK;} $_len . $LF; warn $@ if $@; return; } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_var->can($_fcn) || do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_len = eval { do { $_var->$_fcn } }; print {$_DAU_R_SOCK;} $_len . $LF; warn $@ if $@; return; } }
$_var->can($_fcn) do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_len = eval { do { $_var->$_fcn } }; print {$_DAU_R_SOCK;} $_len . $LF; warn $@ if $@; return; } }
Truth table0%0/3
A || B
A= $_var->can($_fcn)B= do { if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { $_obj_keys; } else { $_len = eval { do { $_var->$_fcn } }; print {$_DAU_R_SOCK;} $_len . $LF; warn $@ if $@; return; } }
ABresult
1X1
011
000
1075 0 ▶ if ( ($_fcn eq 'keys' || $_fcn eq 'SCALAR') &&
Branch: 1 branch
BranchTrueFalseTotal
if ($_fcn eq 'keys' || $_fcn eq 'SCALAR' and $_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) { } 0 0 0
Condition0%0/9
$_fcn eq "keys" || $_fcn eq "SCALAR" and $_var->can("NEXTKEY") || $_var->can("FETCHSIZE")
!ll&&!rl&&r
000
$_fcn eq "keys" or $_fcn eq "SCALAR"
l!l&&r!l&&!r
000
$_var->can("NEXTKEY") or $_var->can("FETCHSIZE")
l!l&&r!l&&!r
000
MC/DC0%0/4
$_fcn eq "keys" || $_fcn eq "SCALAR" and $_var->can("NEXTKEY") || $_var->can("FETCHSIZE")
$_fcn eq "keys" $_fcn eq "SCALAR" $_var->can("NEXTKEY") $_var->can("FETCHSIZE")
Truth table0%0/7
A or B and C or D
A= $_fcn eq "keys"B= $_fcn eq "SCALAR"C= $_var->can("NEXTKEY")D= $_var->can("FETCHSIZE")
ABCDresult
00XX0
1X000
01000
1X1X1
1X011
011X1
01011
1076 ($_var->can('NEXTKEY') || $_var->can('FETCHSIZE')) ) {
1077 0 $_obj_keys;
1078 }
1079 else {
1080 0 $_len = eval { $_var->$_fcn() };
1081 0 print {$_DAU_R_SOCK} $_len.$LF;
1082  
1083 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1084 0 return;
1085 }
1086 };
1087  
1088 0 $_len = eval { $_code->($_var) };
1089 0 print {$_DAU_R_SOCK} $_len.$LF;
1090  
1091 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1092 0 return;
1093 },
1094  
1095 0 );
1096  
1097 MCE::Shared::Queue::_init_mgr(
1098 \$_DAU_R_SOCK, \%_obj, \%_output_function, $_freeze, $_thaw
1099 0 ▶ ) if $INC{'MCE/Shared/Queue.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Queue.pm"} 0 0 0
1100  
1101 MCE::Shared::Handle::_init_mgr(
1102 \$_DAU_R_SOCK, \%_obj, \%_output_function, $_freeze, $_thaw
1103 0 ▶ ) if $INC{'MCE/Shared/Handle.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Handle.pm"} 0 0 0
1104  
1105 MCE::Shared::Condvar::_init_mgr(
1106 \$_DAU_R_SOCK, \%_obj, \%_output_function
1107 0 ▶ ) if $INC{'MCE/Shared/Condvar.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Condvar.pm"} 0 0 0
1108  
1109 # --------------------------------------------------------------------------
1110  
1111 # Call on hash function.
1112  
1113 0 ▶ if ($_is_MSWin32) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_is_MSWin32) { } 0 0 0
1114 # The normal loop hangs on Windows when processes/threads start/exit.
1115 # Using ioctl() properly, https://www.perlmonks.org/?node_id=780083
1116  
1117 0 my $_val_bytes = pack('L', 0);
1118 0 my ($_count, $_nbytes, $_start);
1119  
1120 0 ▶ while (!$_done) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_done) 0 0 0
1121 0 $_start = time, $_count = 1;
1122  
1123 # MSWin32 FIONREAD
1124 0 IOCTL: ioctl($_DAT_R_SOCK, 0x4004667f, $_val_bytes);
1125  
1126 0 ▶ unless ($_nbytes = unpack('L', $_val_bytes)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_nbytes = unpack("L", $_val_bytes)) 0 0 0
1127 0 ▶ if ($_count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_count) { } 0 0 0
1128 # delay after a while to not consume a CPU core
1129 0 ▶ $_count = 0 if ++$_count % 50 == 0 && time - $_start > 0.030;
Branch: 1 branch
BranchTrueFalseTotal
if ++$_count % 50 == 0 and &MCE::Shared::Server::time() - $_start > "0.03" 0 0 0
Condition0%0/3
++$_count % 50 == 0 and &MCE::Shared::Server::time() - $_start > "0.03"
!ll&&!rl&&r
000
MC/DC0%0/2
++$_count % 50 == 0 and &MCE::Shared::Server::time() - $_start > "0.03"
++$_count % 50 == 0 &MCE::Shared::Server::time() - $_start > "0.03"
Truth table0%0/3
A and B
A= ++$_count % 50 == 0B= &MCE::Shared::Server::time() - $_start > "0.03"
ABresult
0X0
100
111
1130 } else {
1131 0 sleep 0.015;
1132 }
1133 0 goto IOCTL;
1134 }
1135  
1136 0 ▶ do {
Branch: 1 branch
BranchTrueFalseTotal
($_nbytes -= 8) >= 8 and do { do { sysread $_DAT_R_SOCK, $_func, 8; $_done = 1, last unless length $_func == 8; $_DAU_R_SOCK = $$_channels[substr $_func, -2, 2, ""]; $_output_function{$_func}->() } } 0 0 0
1137 0 sysread($_DAT_R_SOCK, $_func, 8);
1138 0 ▶ $_done = 1, last() unless length($_func) == 8;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_func == 8 0 0 0
1139 0 $_DAU_R_SOCK = $_channels->[ substr($_func, -2, 2, '') ];
1140  
1141 0 $_output_function{$_func}();
1142  
1143 } while (($_nbytes -= 8) >= 8);
1144 }
1145 }
1146 else {
1147 0 ▶ while (!$_done) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_done) 0 0 0
1148 0 $_func = <$_DAT_R_SOCK>;
1149 0 ▶ last() unless length($_func) == 6;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_func == 6 0 0 0
1150 0 $_DAU_R_SOCK = $_channels->[ <$_DAT_R_SOCK> ];
1151  
1152 0 $_output_function{$_func}();
1153 }
1154 }
1155  
1156 0 _exit();
1157 }
1158  
1159 ###############################################################################
1160 ## ----------------------------------------------------------------------------
1161 ## Object package.
1162 ##
1163 ###############################################################################
1164  
1165 package MCE::Shared::Object;
1166  
1167 43 ▶use Scalar::Util qw( looks_like_number reftype );
Subroutine BEGIN: called CC=1 SCAR=0.0
1168 43 ▶use MCE::Shared::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
1169 43 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
1170  
1171 use constant {
1172 43 ▶ _WNOHANG => ( $INC{'POSIX.pm'} )
Branch: 2 branches
BranchTrueFalseTotal
$INC{'POSIX.pm'} ? : 0 43 43
$^O eq 'solaris' ? : 0 43 43
1173 ? &POSIX::WNOHANG : ( $^O eq 'solaris' ) ? 64 : 1
1174 43 ▶};
Subroutine BEGIN: called CC=3 SCAR=11.0
1175 use constant {
1176 43 _ID => 0, _CLASS => 1, _ENCODE => 2, _DECODE => 3, # shared object
1177 _DREF => 4, _ITER => 5, _MUTEX => 6,
1178 43 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
1179 use constant {
1180 43 _UNDEF => 0, _ARRAY => 1, _SCALAR => 2, # wantarray
1181 43 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
1182  
1183 ## Below, no circular reference to original, therefore no memory leaks.
1184  
1185 use overload (
1186 q("") => \&MCE::Shared::Base::_stringify,
1187 q(0+) => \&MCE::Shared::Base::_numify,
1188 q(@{}) => sub {
1189 43 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
1190 7 ▶ $_[0]->[_DREF] || do {
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
$_[0][4] or do { local $@; my $c = $_[0][1]; ($c) = $c =~ /(.*)/; return $_[0] unless eval " eval { require $c }; $c->can('TIEARRAY') "; tie my @a, __PACKAGE__, bless([@{$_[0];}[0..3]], __PACKAGE__); $_[0][4] = \@a } 7 0 7
1191 7 local $@; my $c = $_[0]->[_CLASS];
1192 7 ($c) = $c =~ /(.*)/; # remove tainted'ness
1193 7 ▶ return $_[0] unless eval qq{ eval { require $c }; $c->can('TIEARRAY') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval " eval { require $c }; $c->can('TIEARRAY') " 0 7 7
1194 7 tie my @a, __PACKAGE__, bless([ @{ $_[0] }[ 0..3 ] ], __PACKAGE__);
1195 7 $_[0]->[_DREF] = \@a;
1196 };
1197 },
1198 q(%{}) => sub {
1199 43 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
1200 9 ▶ $_[0]->[_DREF] || do {
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
$_[0][4] or do { local $@; my $c = $_[0][1]; ($c) = $c =~ /(.*)/; return $_[0] unless eval " eval { require $c }; $c->can('TIEHASH') "; tie my %h, __PACKAGE__, bless([@{$_[0];}[0..3]], __PACKAGE__); $_[0][4] = \%h } 9 0 9
1201 9 local $@; my $c = $_[0]->[_CLASS];
1202 9 ($c) = $c =~ /(.*)/; # remove tainted'ness
1203 9 ▶ return $_[0] unless eval qq{ eval { require $c }; $c->can('TIEHASH') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval " eval { require $c }; $c->can('TIEHASH') " 0 9 9
1204 9 tie my %h, __PACKAGE__, bless([ @{ $_[0] }[ 0..3 ] ], __PACKAGE__);
1205 9 $_[0]->[_DREF] = \%h;
1206 };
1207 },
1208 q(${}) => sub {
1209 43 ▶ no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
1210 0 ▶ $_[0]->[_DREF] || do {
Subroutine __ANON__: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
$_[0][4] or do { local $@; my $c = $_[0][1]; ($c) = $c =~ /(.*)/; return $_[0] unless eval " eval { require $c }; $c->can('TIESCALAR') "; tie my $s, __PACKAGE__, bless([@{$_[0];}[0..3]], __PACKAGE__); $_[0][4] = \$s } 0 0 0
1211 0 local $@; my $c = $_[0]->[_CLASS];
1212 0 ($c) = $c =~ /(.*)/; # remove tainted'ness
1213 0 ▶ return $_[0] unless eval qq{ eval { require $c }; $c->can('TIESCALAR') };
Branch: 1 branch
BranchTrueFalseTotal
unless eval " eval { require $c }; $c->can('TIESCALAR') " 0 0 0
1214 0 tie my $s, __PACKAGE__, bless([ @{ $_[0] }[ 0..3 ] ], __PACKAGE__);
1215 0 $_[0]->[_DREF] = \$s;
1216 };
1217 },
1218 43 fallback => 1
1219 43 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
1220  
1221 43 ▶no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
1222  
1223 43 my ($_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_chn, $_dat_ex, $_dat_un);
1224  
1225 43 my $_blessed = \&Scalar::Util::blessed;
1226  
1227 BEGIN {
1228 0 ▶ $_dat_ex = sub { _croak (
Subroutine __ANON__: not called CC=1 SCAR=6.9
1229 "\nPlease start the shared-manager process manually when ready.\n",
1230 "See section labeled \"Extra Functionality\" in MCE::Shared.\n\n"
1231 43 ▶ ) };
Subroutine BEGIN: called CC=1 SCAR=0.0
1232 }
1233  
1234 # Hook for threads.
1235  
1236 sub CLONE {
1237 0 ▶ $_tid = threads->tid() if $INC{'threads.pm'};
Subroutine CLONE: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"threads.pm"} 0 0 0
1238 0 ▶ &_init($_tid) if $_tid;
Branch: 1 branch
BranchTrueFalseTotal
if $_tid 0 0 0
1239 }
1240  
1241 # Private functions.
1242  
1243 sub DESTROY {
1244 113 ▶ return if $_stopped;
Subroutine DESTROY: called CC=14 SCAR=30.1
Branch: 1 branch
BranchTrueFalseTotal
if $_stopped 3 110 113
1245 110 ▶ return unless ( $_is_client && defined $_svr_pid && defined $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_client and defined $_svr_pid and defined $_[0] 0 110 110
Condition33%2/6
$_is_client and defined $_svr_pid and defined $_[0]
!ll&&!rl&&r
00110
$_is_client and defined $_svr_pid
!ll&&!rl&&r
00110
MC/DC0%0/3
$_is_client and defined $_svr_pid and defined $_[0]
$_is_client defined $_svr_pid defined $_[0]
Truth table25%1/4
A and B and C
A= $_is_clientB= defined $_svr_pidC= defined $_[0]
ABCresult
0XX0
10X0
1100
1111
1246  
1247 110 ▶ if ( $_spawn_child && $_init_pid && $_init_pid eq "$$.$_tid" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid") 58 52 110
Condition50%3/6
$_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid"
!ll&&!rl&&r
05258
$_spawn_child and $_init_pid
!ll&&!rl&&r
00110
MC/DC33%1/3
$_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid"
$_spawn_child $_init_pid $_init_pid eq "${$}.$_tid"
Truth table50%2/4
A and B and C
A= $_spawn_childB= $_init_pidC= $_init_pid eq "${$}.$_tid"
ABCresult
0XX0
10X0
1100
1111
1248 58 local ($!, $?);
1249 58 ▶ return if ( ! $_svr_pid || waitpid($_svr_pid, _WNOHANG) );
Branch: 1 branch
BranchTrueFalseTotal
if not $_svr_pid or waitpid $_svr_pid, 1 0 58 58
Condition33%1/3
not $_svr_pid or waitpid $_svr_pid, 1
l!l&&r!l&&!r
0058
MC/DC0%0/2
not $_svr_pid or waitpid $_svr_pid, 1
not $_svr_pid waitpid $_svr_pid, 1
Truth table33%1/3
not(A) or B
A= not $_svr_pidB= waitpid $_svr_pid, 1
ABresult
1X1
011
000
1250 }
1251  
1252 110 my $_id = $_[0]->[_ID];
1253  
1254 110 ▶ if ( exists $_new{ $_id } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $_new{$_id}) 48 62 110
1255 48 ▶ my $_pid = $_tid ? $$ .'.'. $_tid : $$;
Branch: 1 branch
BranchTrueFalseTotal
$_tid ? : 0 48 48
1256  
1257 48 ▶ if ($_new{ $_id } eq $_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_new{$_id} eq $_pid) 48 0 48
1258 48 ▶ return if $MCE::Signal::KILLED;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::KILLED 0 48 48
1259  
1260 delete($_all{ $_id }), delete($_obj{ $_id }),
1261 delete($_new{ $_id }), delete($_ob2{ $_id }),
1262 48 delete($_ob3{"$_id:count"});
1263  
1264 48 _req1('M~DES', $_id.$LF);
1265 }
1266 }
1267  
1268 110 return;
1269 }
1270  
1271 0 ▶sub _croak { goto &MCE::Shared::Base::_croak }
Subroutine _croak: not called CC=1 SCAR=6.9
1272  
1273 2 ▶sub SHARED_ID { $_[0]->[_ID] }
Subroutine SHARED_ID: called CC=1 SCAR=0.0
1274  
1275 9 ▶sub TIEARRAY { $_[1] }
Subroutine TIEARRAY: called CC=1 SCAR=0.0
1276 3 ▶sub TIEHANDLE { $_[1] }
Subroutine TIEHANDLE: called CC=1 SCAR=0.0
1277 9 ▶sub TIEHASH { $_[1] }
Subroutine TIEHASH: called CC=1 SCAR=0.0
1278 0 ▶sub TIESCALAR { $_[1] }
Subroutine TIESCALAR: not called CC=1 SCAR=6.9
1279  
1280 sub _reset {
1281 MCE::Shared::Object::_init_condvar(
1282 $_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, \%_obj,
1283 $_freeze, $_thaw
1284 84 ▶ ) if $INC{'MCE/Shared/Condvar.pm'};
Subroutine _reset: called CC=4 SCAR=13.9
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Condvar.pm"} 8 76 84
1285  
1286 MCE::Shared::Object::_init_handle(
1287 $_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, \%_obj,
1288 $_freeze, $_thaw
1289 84 ▶ ) if $INC{'MCE/Shared/Handle.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Handle.pm"} 4 80 84
1290  
1291 MCE::Shared::Object::_init_queue(
1292 $_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, \%_obj,
1293 $_freeze, $_thaw
1294 84 ▶ ) if $INC{'MCE/Shared/Queue.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"MCE/Shared/Queue.pm"} 22 62 84
1295 }
1296  
1297 sub _start {
1298 43 ▶ $_chn = $_SVR->{_data_channels} + 1;
Subroutine _start: called CC=1 SCAR=0.1
1299 43 $_DAT_LOCK = $_SVR->{'_mutex_'.$_chn};
1300 43 $_DAT_W_SOCK = $_SVR->{_dat_w_sock}[0];
1301 43 $_DAU_W_SOCK = $_SVR->{_dat_w_sock}[$_chn];
1302  
1303 # inlined for performance
1304 $_dat_ex = sub {
1305 2005 ▶ my $_pid = $_tid ? $$ .'.'. $_tid : $$;
Subroutine __ANON__: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
$_tid ? : 0 2005 2005
1306 MCE::Util::_sysread($_DAT_LOCK->{_r_sock}, my($b), 1), $_DAT_LOCK->{ $_pid } = 1
1307 2005 ▶ unless $_DAT_LOCK->{ $_pid };
Branch: 1 branch
BranchTrueFalseTotal
unless $_DAT_LOCK->{$_pid} 2005 0 2005
1308 43 };
1309 $_dat_un = sub {
1310 2005 ▶ my $_pid = $_tid ? $$ .'.'. $_tid : $$;
Subroutine __ANON__: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
$_tid ? : 0 2005 2005
1311 CORE::syswrite($_DAT_LOCK->{_w_sock}, '0'), $_DAT_LOCK->{ $_pid } = 0
1312 2005 ▶ if $_DAT_LOCK->{ $_pid };
Branch: 1 branch
BranchTrueFalseTotal
if $_DAT_LOCK->{$_pid} 2005 0 2005
1313 43 };
1314  
1315 43 _reset();
1316 }
1317  
1318 sub _stop {
1319 15 ▶ $_DAT_LOCK = $_DAT_W_SOCK = $_DAU_W_SOCK = $_chn = $_dat_un = undef;
Subroutine _stop: called CC=1 SCAR=0.2
1320  
1321 0 ▶ $_dat_ex = sub { _croak (
Subroutine __ANON__: not called CC=1 SCAR=6.9
1322 "\nPlease start the shared-manager process manually when ready.\n",
1323 "See section labeled \"Extra Functionality\" in MCE::Shared.\n\n"
1324 15 ) };
1325  
1326 15 return;
1327 }
1328  
1329 sub _get_channel_id {
1330 28 ▶ local $\ = undef if (defined $\);
Subroutine _get_channel_id: called CC=6 SCAR=18.5
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 28 28
1331 28 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 28 28
1332 28 local $MCE::Signal::SIG;
1333  
1334 28 my $_ret;
1335  
1336 {
1337 28 local $MCE::Signal::IPC = 1;
1338 28 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 28 28
1339  
1340 28 print {$_DAT_W_SOCK} 'M~CID'.$LF . $_chn.$LF;
1341 28 chomp($_ret = <$_DAU_W_SOCK>);
1342  
1343 28 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 28 0 28
1344 }
1345  
1346 28 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 28 28
1347  
1348 28 return $_ret;
1349 }
1350  
1351 sub _init {
1352 28 ▶ return unless defined $_SVR;
Subroutine _init: called CC=4 SCAR=14.6
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_SVR 0 28 28
1353  
1354 28 ▶ my $_id = $_[0] // &_get_channel_id();
Condition33%1/3
$_[0] // &_get_channel_id()
l!l&&r!l&&!r
0280
MC/DC0%0/2
$_[0] // &_get_channel_id()
$_[0] &_get_channel_id()
Truth table33%1/3
A // B
A= $_[0]B= &_get_channel_id()
ABresult
1X1
011
000
1355 28 ▶ $_id = $$ if ( $_id !~ /\d+/ );
Branch: 1 branch
BranchTrueFalseTotal
unless $_id =~ /\d+/ 0 28 28
1356  
1357 28 $_chn = abs($_id) % $_SVR->{_data_channels} + 1;
1358 28 $_DAT_LOCK = $_SVR->{'_mutex_'.$_chn};
1359 28 $_DAU_W_SOCK = $_SVR->{_dat_w_sock}[$_chn];
1360  
1361 28 %_new = (), _reset();
1362  
1363 28 return;
1364 }
1365  
1366 ###############################################################################
1367 ## ----------------------------------------------------------------------------
1368 ## Private routines.
1369 ##
1370 ###############################################################################
1371  
1372 # Called by AUTOLOAD, STORE, set, and keys.
1373  
1374 sub _auto {
1375 1228 ▶ my $_wa = !defined wantarray ? _UNDEF : wantarray ? _ARRAY : _SCALAR;
Subroutine _auto: called CC=12 SCAR=25.0
Branch: 2 branches
BranchTrueFalseTotal
!defined(wantarray) ? : 312 916 1228
wantarray ? : 382 534 916
1376  
1377 1228 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 1228 1228
1378 1228 local $MCE::Signal::SIG;
1379  
1380 1228 my $_buf;
1381  
1382 {
1383 1228 local $MCE::Signal::IPC = 1;
1384 1228 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 1228 1228
1385  
1386 1228 ▶ if ( @_ == 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 155 1073 1228
1387 155 print({$_DAT_W_SOCK} 'M~OB0'.$LF . $_chn.$LF),
1388 155 print({$_DAU_W_SOCK} $_[1]->[_ID].$LF . $_[0].$LF . $_wa.$LF);
1389 }
1390 else {
1391 1073 my ( $_fcn, $_id, $_buf ) = ( shift, shift()->[_ID], $_freeze->([ @_ ]) );
1392 1073 my $_tmp = $_id.$LF . $_fcn.$LF . $_wa.$LF . length($_buf).$LF;
1393 1073 print({$_DAT_W_SOCK} 'M~OBJ'.$LF . $_chn.$LF),
1394 1073 print({$_DAU_W_SOCK} $_tmp, $_buf);
1395 }
1396  
1397 1228 ▶ if ( $_wa ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_wa) 916 312 1228
1398 916 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 916 916
1399 916 chomp(my $_len = <$_DAU_W_SOCK>);
1400 916 read($_DAU_W_SOCK, $_buf, $_len);
1401 }
1402  
1403 1228 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 1228 0 1228
1404 }
1405  
1406 1228 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 1228 1228
1407  
1408 1228 ▶ return unless $_wa;
Branch: 1 branch
BranchTrueFalseTotal
unless $_wa 312 916 1228
1409 916 ▶ return ( $_wa != _ARRAY ) ? $_thaw->($_buf)[0] : @{ $_thaw->($_buf) };
Branch: 1 branch
BranchTrueFalseTotal
$_wa != 1 ? : 534 382 916
1410 }
1411  
1412 # Called by MCE::Hobo ( ->join, ->wait_one ).
1413  
1414 sub _get_hobo_data {
1415 49 ▶ if ( $_spawn_child && $_init_pid && $_init_pid eq "$$.$_tid" ) {
Subroutine _get_hobo_data: called CC=13 SCAR=28.8
Branch: 1 branch
BranchTrueFalseTotal
if ($_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid") 49 0 49
Condition33%2/6
$_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid"
!ll&&!rl&&r
0049
$_spawn_child and $_init_pid
!ll&&!rl&&r
0049
MC/DC0%0/3
$_spawn_child and $_init_pid and $_init_pid eq "${$}.$_tid"
$_spawn_child $_init_pid $_init_pid eq "${$}.$_tid"
Truth table25%1/4
A and B and C
A= $_spawn_childB= $_init_pidC= $_init_pid eq "${$}.$_tid"
ABCresult
0XX0
10X0
1100
1111
1416 49 local ($!, $?);
1417 49 ▶ return if ( ! $_svr_pid || waitpid($_svr_pid, _WNOHANG) );
Branch: 1 branch
BranchTrueFalseTotal
if not $_svr_pid or waitpid $_svr_pid, 1 0 49 49
Condition33%1/3
not $_svr_pid or waitpid $_svr_pid, 1
l!l&&r!l&&!r
0049
MC/DC0%0/2
not $_svr_pid or waitpid $_svr_pid, 1
not $_svr_pid waitpid $_svr_pid, 1
Truth table33%1/3
not(A) or B
A= not $_svr_pidB= waitpid $_svr_pid, 1
ABresult
1X1
011
000
1418 }
1419  
1420 49 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 49 49
1421 49 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 49 49
1422 49 local $MCE::Signal::SIG;
1423  
1424 49 my ($_result, $_error);
1425  
1426 {
1427 49 local $MCE::Signal::IPC = 1;
1428 49 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 49 49
1429  
1430 49 print({$_DAT_W_SOCK} 'O~DAT'.$LF . $_chn.$LF),
1431 49 print({$_DAU_W_SOCK} $_[0]->[_ID].$LF . $_[1].$LF);
1432  
1433 49 chomp(my $_le1 = <$_DAU_W_SOCK>),
1434 chomp(my $_le2 = <$_DAU_W_SOCK>);
1435  
1436 49 ▶ read($_DAU_W_SOCK, $_error, $_le1) if $_le1;
Branch: 1 branch
BranchTrueFalseTotal
if $_le1 0 49 49
1437 49 ▶ read($_DAU_W_SOCK, $_result, $_le2) if $_le2;
Branch: 1 branch
BranchTrueFalseTotal
if $_le2 34 15 49
1438  
1439 49 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 49 0 49
1440 }
1441  
1442 49 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 49 49
1443  
1444 49 return ($_result, $_error);
1445 }
1446  
1447 # Called by await, dequeue_timed, rewind, broadcast, signal, timedwait, and
1448 # wait. Including CLOSE, DESTROY, and destroy.
1449  
1450 sub _req1 {
1451 78 ▶ return unless defined $_DAU_W_SOCK; # (in cleanup)
Subroutine _req1: called CC=7 SCAR=20.2
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_DAU_W_SOCK 0 78 78
1452  
1453 78 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 78 78
1454 78 ▶ local $/ = $LF if ($/ ne $LF );
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 78 78
1455 78 local $MCE::Signal::SIG;
1456  
1457 78 my $_ret;
1458  
1459 {
1460 78 local $MCE::Signal::IPC = 1;
1461 78 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 78 78
1462  
1463 78 print({$_DAT_W_SOCK} $_[0].$LF . $_chn.$LF),
1464 78 print({$_DAU_W_SOCK} $_[1]);
1465 78 chomp($_ret = <$_DAU_W_SOCK>);
1466  
1467 78 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 78 0 78
1468 }
1469  
1470 78 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 78 78
1471  
1472 78 $_ret;
1473 }
1474  
1475 # Called by PRINT, PRINTF, STORE, ins_inplace, and set.
1476  
1477 sub _req2 {
1478 224 ▶ local $\ = undef if (defined $\);
Subroutine _req2: called CC=5 SCAR=16.6
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 224 224
1479 224 local $MCE::Signal::SIG;
1480  
1481 {
1482 224 local $MCE::Signal::IPC = 1;
1483 224 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 224 224
1484  
1485 224 print({$_DAT_W_SOCK} $_[0].$LF . $_chn.$LF),
1486 224 print({$_DAU_W_SOCK} $_[1], $_[2]);
1487  
1488 224 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 224 0 224
1489 }
1490  
1491 224 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 224 224
1492  
1493 224 1;
1494 }
1495  
1496 # Called by CLEAR and clear.
1497  
1498 sub _req3 {
1499 40 ▶ my ( $_fcn, $self ) = @_;
Subroutine _req3: called CC=7 SCAR=20.3
1500  
1501 40 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 40 40
1502 40 ▶ local $/ = $LF if ($/ ne $LF );
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 40 40
1503 40 local $MCE::Signal::SIG;
1504  
1505 40 ▶ delete $self->[_ITER] if defined $self->[_ITER];
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->[5] 0 40 40
1506  
1507 {
1508 40 local $MCE::Signal::IPC = 1;
1509 40 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 40 40
1510  
1511 40 print({$_DAT_W_SOCK} 'O~CLR'.$LF . $_chn.$LF),
1512 40 print({$_DAU_W_SOCK} $self->[_ID].$LF . $_fcn.$LF);
1513  
1514 40 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 40 0 40
1515 }
1516  
1517 40 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 40 40
1518  
1519 40 return;
1520 }
1521  
1522 # Called by FETCH and get.
1523  
1524 sub _req4 {
1525 157 ▶ local $\ = undef if (defined $\);
Subroutine _req4: called CC=13 SCAR=29.4
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 157 157
1526 157 ▶ local $/ = $LF if ($/ ne $LF );
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 157 157
1527 157 local $MCE::Signal::SIG;
1528  
1529 157 my ( $_key, $_len, $_buf );
1530  
1531 157 ▶ if ( @_ == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3) 104 53 157
1532 104 ▶ $_key = ref($_[2]) ? $_[2].'0' : $_freeze->(\$_[2]).'1';
Branch: 1 branch
BranchTrueFalseTotal
ref $_[2] ? : 0 104 104
1533 }
1534  
1535 {
1536 157 local $MCE::Signal::IPC = 1;
1537 157 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 157 157
1538  
1539 157 print({$_DAT_W_SOCK} 'O~FCH'.$LF . $_chn.$LF),
1540 157 print({$_DAU_W_SOCK} $_[1]->[_ID].$LF . $_[0].$LF . length($_key).$LF, $_key);
1541 157 chomp($_len = <$_DAU_W_SOCK>);
1542  
1543 157 ▶ read($_DAU_W_SOCK, $_buf, $_len) if ($_len >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len >= 0 156 1 157
1544  
1545 157 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 157 0 157
1546 }
1547  
1548 157 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 157 157
1549  
1550 157 ▶ return undef if ($_len < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len < 0 1 156 157
1551  
1552 156 ▶ if ( $_[1]->[_DECODE] && $_[0] eq 'FETCH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1][3] and $_[0] eq "FETCH") 0 156 156
Condition33%1/3
$_[1][3] and $_[0] eq "FETCH"
!ll&&!rl&&r
15600
MC/DC0%0/2
$_[1][3] and $_[0] eq "FETCH"
$_[1][3] $_[0] eq "FETCH"
Truth table33%1/3
A and B
A= $_[1][3]B= $_[0] eq "FETCH"
ABresult
0X0
100
111
1553 0 local $@; $_buf = $_thaw->($_buf)[0];
1554 0 ▶ return eval { $_[1]->[_DECODE]->($_buf) } || $_buf;
Condition0%0/3
eval { do { $_[1][3]->($_buf) } } || $_buf
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $_[1][3]->($_buf) } } || $_buf
eval { do { $_[1][3]->($_buf) } } $_buf
Truth table0%0/3
A || B
A= eval { do { $_[1][3]->($_buf) } }B= $_buf
ABresult
1X1
011
000
1555 }
1556  
1557 156 $_thaw->($_buf)[0];
1558 }
1559  
1560 # Called by FETCHSIZE, SCALAR, keys, and pending.
1561  
1562 sub _size {
1563 4 ▶ local $\ = undef if (defined $\);
Subroutine _size: called CC=7 SCAR=20.3
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 4 4
1564 4 ▶ local $/ = $LF if ($/ ne $LF );
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 4 4
1565 4 local $MCE::Signal::SIG;
1566  
1567 4 my $_size;
1568  
1569 {
1570 4 local $MCE::Signal::IPC = 1;
1571 4 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 4 4
1572  
1573 4 print({$_DAT_W_SOCK} 'O~SZE'.$LF . $_chn.$LF),
1574 4 print({$_DAU_W_SOCK} $_[1]->[_ID].$LF . $_[0].$LF);
1575 4 chomp($_size = <$_DAU_W_SOCK>);
1576  
1577 4 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 4 0 4
1578 }
1579  
1580 4 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 4 4
1581  
1582 4 ▶ length($_size) ? int($_size) : undef;
Branch: 1 branch
BranchTrueFalseTotal
length $_size ? : 4 0 4
1583 }
1584  
1585 ###############################################################################
1586 ## ----------------------------------------------------------------------------
1587 ## Common methods.
1588 ##
1589 ###############################################################################
1590  
1591 43 our $AUTOLOAD; # MCE::Shared::Object::<method_name>
1592  
1593 sub AUTOLOAD {
1594 235 ▶ my $_fcn = $AUTOLOAD; substr($_fcn, 0, rindex($_fcn,':') + 1, '');
Subroutine AUTOLOAD: called CC=1 SCAR=0.0
1595  
1596 # save this method for future calls
1597 43 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
1598 235 ▶ *{ $AUTOLOAD } = sub { _auto($_fcn, @_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
1599  
1600 235 goto &{ $AUTOLOAD };
1601 }
1602  
1603 # blessed ( )
1604  
1605 sub blessed {
1606 17 ▶ $_[0]->[_CLASS];
Subroutine blessed: called CC=1 SCAR=0.0
1607 }
1608  
1609 # decoder ( CODE )
1610 # decoder ( )
1611  
1612 sub decoder {
1613 0 ▶ $_[0]->[_DECODE] = $_[1] if (@_ == 2 && (ref $_[1] eq 'CODE' || !$_[1]));
Subroutine decoder: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 and ref $_[1] eq "CODE" || !$_[1] 0 0 0
Condition0%0/6
@_ == 2 and ref $_[1] eq "CODE" || !$_[1]
!ll&&!rl&&r
000
ref $_[1] eq "CODE" or not $_[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
@_ == 2 and ref $_[1] eq "CODE" || !$_[1]
@_ == 2 ref $_[1] eq "CODE" not $_[1]
Truth table0%0/4
A and B or not(C)
A= @_ == 2B= ref $_[1] eq "CODE"C= not $_[1]
ABCresult
0XX0
1000
11X1
1011
1614 0 $_[0]->[_DECODE];
1615 }
1616  
1617 # encoder ( CODE )
1618 # encoder ( )
1619  
1620 sub encoder {
1621 0 ▶ $_[0]->[_ENCODE] = $_[1] if (@_ == 2 && (ref $_[1] eq 'CODE' || !$_[1]));
Subroutine encoder: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if @_ == 2 and ref $_[1] eq "CODE" || !$_[1] 0 0 0
Condition0%0/6
@_ == 2 and ref $_[1] eq "CODE" || !$_[1]
!ll&&!rl&&r
000
ref $_[1] eq "CODE" or not $_[1]
l!l&&r!l&&!r
000
MC/DC0%0/3
@_ == 2 and ref $_[1] eq "CODE" || !$_[1]
@_ == 2 ref $_[1] eq "CODE" not $_[1]
Truth table0%0/4
A and B or not(C)
A= @_ == 2B= ref $_[1] eq "CODE"C= not $_[1]
ABCresult
0XX0
1000
11X1
1011
1622 0 $_[0]->[_ENCODE];
1623 }
1624  
1625 # destroy ( { unbless => 1 } )
1626 # destroy ( )
1627  
1628 sub destroy {
1629 0 ▶ my $_id = $_[0]->[_ID];
Subroutine destroy: not called CC=8 SCAR=42.8
1630 0 ▶ my $_un = (ref $_[1] eq 'HASH' && $_[1]->{'unbless'}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[1] eq 'HASH' && $_[1]{'unbless'} ? : 0 0 0
Condition0%0/3
ref $_[1] eq "HASH" and $_[1]{"unbless"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[1] eq "HASH" and $_[1]{"unbless"}
ref $_[1] eq "HASH" $_[1]{"unbless"}
Truth table0%0/3
A and B
A= ref $_[1] eq "HASH"B= $_[1]{"unbless"}
ABresult
0X0
100
111
1631 0 ▶ my $_item = (defined wantarray) ? $_[0]->export({ unbless => $_un }) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined wantarray ? : 0 0 0
1632 0 ▶ my $_pid = $_tid ? $$ .'.'. $_tid : $$;
Branch: 1 branch
BranchTrueFalseTotal
$_tid ? : 0 0 0
1633  
1634 0 delete($_all{ $_id }), delete($_obj{ $_id });
1635  
1636 0 ▶ if (defined $_svr_pid && exists $_new{ $_id } && $_new{ $_id } eq $_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_svr_pid and exists $_new{$_id} and $_new{$_id} eq $_pid) 0 0 0
Condition0%0/6
defined $_svr_pid and exists $_new{$_id} and $_new{$_id} eq $_pid
!ll&&!rl&&r
000
defined $_svr_pid and exists $_new{$_id}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_svr_pid and exists $_new{$_id} and $_new{$_id} eq $_pid
defined $_svr_pid exists $_new{$_id} $_new{$_id} eq $_pid
Truth table0%0/4
A and B and C
A= defined $_svr_pidB= exists $_new{$_id}C= $_new{$_id} eq $_pid
ABCresult
0XX0
10X0
1100
1111
1637 0 delete($_new{ $_id }), _req1('M~DES', $_id.$LF);
1638 }
1639  
1640 0 $_[0] = undef;
1641 0 $_item;
1642 }
1643  
1644 # export ( { unbless => 1 }, key [, key, ... ] )
1645 # export ( key [, key, ... ] )
1646 # export ( )
1647  
1648 sub export {
1649 0 ▶ my $_ob = shift;
Subroutine export: not called CC=37 SCAR=72.5
1650 0 my $_id = $_ob->[_ID];
1651 0 ▶ my $_lkup = ref($_[0]) eq 'HASH' ? shift : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] eq 'HASH' ? : 0 0 0
1652  
1653 # safety for circular references to not loop endlessly
1654 0 ▶ return $_lkup->{ $_id } if exists $_lkup->{ $_id };
Branch: 1 branch
BranchTrueFalseTotal
if exists $_lkup->{$_id} 0 0 0
1655  
1656 0 ▶ my $_tmp = @_ ? $_freeze->([ @_ ]) : '';
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
1657 0 my $_buf = $_id.$LF . length($_tmp).$LF;
1658 0 my $_class = $_ob->[_CLASS];
1659 0 my $_item;
1660  
1661 0 { local $@; MCE::Shared::_use($_class); }
1662  
1663 {
1664 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
1665 0 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 0 0
1666 0 local $MCE::Signal::SIG;
1667  
1668 0 my $_len;
1669  
1670 {
1671 0 local $MCE::Signal::IPC = 1;
1672 0 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 0 0
1673  
1674 0 print({$_DAT_W_SOCK} 'M~EXP'.$LF . $_chn.$LF),
1675 0 print({$_DAU_W_SOCK} $_buf, $_tmp); undef $_buf;
1676 0 chomp($_len = <$_DAU_W_SOCK>);
1677  
1678 0 ▶ read($_DAU_W_SOCK, $_buf, $_len) if ($_len >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len >= 0 0 0 0
1679  
1680 0 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 0 0 0
1681 }
1682  
1683 0 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 0 0
1684  
1685 0 ▶ return undef if ($_len < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len < 0 0 0 0
1686  
1687 0 $_item = $_lkup->{ $_id } = Storable::thaw($_buf);
1688 0 undef $_buf;
1689 }
1690  
1691 0 my $_data; local $_;
1692  
1693 ## no critic
1694 0 ▶ if ( $_class->isa('MCE::Shared::Array') || $_class->isa('Tie::StdArray') ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_class->isa('MCE::Shared::Array') or $_class->isa('Tie::StdArray')) { } 0 0 0
elsif ($_class->isa('MCE::Shared::Hash') or $_class->isa('Tie::StdHash')) { } 0 0 0
elsif ($_class->isa('MCE::Shared::Scalar') or $_class->isa('Tie::StdScalar')) { } 0 0 0
Condition0%0/3
$_class->isa("MCE::Shared::Array") or $_class->isa("Tie::StdArray")
l!l&&r!l&&!r
000
MC/DC0%0/2
$_class->isa("MCE::Shared::Array") or $_class->isa("Tie::StdArray")
$_class->isa("MCE::Shared::Array") $_class->isa("Tie::StdArray")
Truth table0%0/3
A or B
A= $_class->isa("MCE::Shared::Array")B= $_class->isa("Tie::StdArray")
ABresult
1X1
011
000
1695 0 ▶ map { $_ = $_->export($_lkup) if $_blessed->($_) && $_->can('export')
Branch: 1 branch
BranchTrueFalseTotal
if &$_blessed($_) and $_->can("export") 0 0 0
Condition0%0/3
&$_blessed($_) and $_->can("export")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed($_) and $_->can("export")
&$_blessed($_) $_->can("export")
Truth table0%0/3
A and B
A= &$_blessed($_)B= $_->can("export")
ABresult
0X0
100
111
1696 0 } @{ $_item };
1697  
1698 0 ▶ return $_lkup->{ $_id } = [ @{ $_item } ] if $_lkup->{'unbless'};
Branch: 1 branch
BranchTrueFalseTotal
if $_lkup->{"unbless"} 0 0 0
1699 }
1700 ▶ elsif ( $_class->isa('MCE::Shared::Hash') || $_class->isa('Tie::StdHash') ) {
Condition0%0/3
$_class->isa("MCE::Shared::Hash") or $_class->isa("Tie::StdHash")
l!l&&r!l&&!r
000
MC/DC0%0/2
$_class->isa("MCE::Shared::Hash") or $_class->isa("Tie::StdHash")
$_class->isa("MCE::Shared::Hash") $_class->isa("Tie::StdHash")
Truth table0%0/3
A or B
A= $_class->isa("MCE::Shared::Hash")B= $_class->isa("Tie::StdHash")
ABresult
1X1
011
000
1701 0 ▶ map { $_ = $_->export($_lkup) if $_blessed->($_) && $_->can('export')
Branch: 1 branch
BranchTrueFalseTotal
if &$_blessed($_) and $_->can("export") 0 0 0
Condition0%0/3
&$_blessed($_) and $_->can("export")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed($_) and $_->can("export")
&$_blessed($_) $_->can("export")
Truth table0%0/3
A and B
A= &$_blessed($_)B= $_->can("export")
ABresult
0X0
100
111
1702 0 } CORE::values %{ $_item };
1703  
1704 0 ▶ return $_lkup->{ $_id } = { %{ $_item } } if $_lkup->{'unbless'};
Branch: 1 branch
BranchTrueFalseTotal
if $_lkup->{"unbless"} 0 0 0
1705 }
1706 ▶ elsif ( $_class->isa('MCE::Shared::Scalar') || $_class->isa('Tie::StdScalar') ) {
Condition0%0/3
$_class->isa("MCE::Shared::Scalar") or $_class->isa("Tie::StdScalar")
l!l&&r!l&&!r
000
MC/DC0%0/2
$_class->isa("MCE::Shared::Scalar") or $_class->isa("Tie::StdScalar")
$_class->isa("MCE::Shared::Scalar") $_class->isa("Tie::StdScalar")
Truth table0%0/3
A or B
A= $_class->isa("MCE::Shared::Scalar")B= $_class->isa("Tie::StdScalar")
ABresult
1X1
011
000
1707 0 ▶ if ( $_blessed->(${ $_item }) && ${ $_item }->can('export') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$_blessed(${$_item;}) and ${$_item;}->can("export")) 0 0 0
Condition0%0/3
&$_blessed(${$_item;}) and ${$_item;}->can("export")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed(${$_item;}) and ${$_item;}->can("export")
&$_blessed(${$_item;}) ${$_item;}->can("export")
Truth table0%0/3
A and B
A= &$_blessed(${$_item;})B= ${$_item;}->can("export")
ABresult
0X0
100
111
1708 0 ${ $_item } = ${ $_item }->export($_lkup);
1709 }
1710 0 ▶ return $_lkup->{ $_id } = \do { my $o = ${ $_item } } if $_lkup->{'unbless'};
Branch: 1 branch
BranchTrueFalseTotal
if $_lkup->{"unbless"} 0 0 0
1711 }
1712 else {
1713 0 ▶ if ( $_class->isa('MCE::Shared::Ordhash') ) { $_data = $_item->[0] }
Branch: 5 branches
BranchTrueFalseTotal
if ($_class->isa('MCE::Shared::Ordhash')) { } 0 0 0
elsif ($_class->isa('MCE::Shared::Cache')) { } 0 0 0
elsif ($_class->isa('Hash::Ordered')) { } 0 0 0
elsif ($_class->isa('Tie::ExtraHash')) { } 0 0 0
elsif ($_class->isa('Tie::IxHash')) { } 0 0 0
1714 0 elsif ( $_class->isa('MCE::Shared::Cache') ) { $_data = $_item->[0] }
1715 0 elsif ( $_class->isa('Hash::Ordered') ) { $_data = $_item->[0] }
1716 0 elsif ( $_class->isa('Tie::ExtraHash') ) { $_data = $_item->[0] }
1717 0 elsif ( $_class->isa('Tie::IxHash') ) { $_data = $_item->[2] }
1718  
1719 0 ▶ if ( reftype $_data eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::reftype($_data) eq 'ARRAY') { } 0 0 0
elsif (builtin::reftype($_data) eq 'HASH') { } 0 0 0
1720 0 ▶ map { $_ = $_->export($_lkup) if $_blessed->($_) && $_->can('export')
Branch: 1 branch
BranchTrueFalseTotal
if &$_blessed($_) and $_->can("export") 0 0 0
Condition0%0/3
&$_blessed($_) and $_->can("export")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed($_) and $_->can("export")
&$_blessed($_) $_->can("export")
Truth table0%0/3
A and B
A= &$_blessed($_)B= $_->can("export")
ABresult
0X0
100
111
1721 0 } @{ $_data };
1722 }
1723 elsif ( reftype $_data eq 'HASH' ) {
1724 0 ▶ map { $_ = $_->export($_lkup) if $_blessed->($_) && $_->can('export')
Branch: 1 branch
BranchTrueFalseTotal
if &$_blessed($_) and $_->can("export") 0 0 0
Condition0%0/3
&$_blessed($_) and $_->can("export")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed($_) and $_->can("export")
&$_blessed($_) $_->can("export")
Truth table0%0/3
A and B
A= &$_blessed($_)B= $_->can("export")
ABresult
0X0
100
111
1725 0 } values %{ $_data };
1726 }
1727 }
1728  
1729 0 $_item;
1730 }
1731  
1732 # iterator ( index [, index, ... ] ) # Array
1733 # iterator ( key [, key, ... ] ) # Cache, Hash, Ordhash
1734 # iterator ( "query string" ) # Cache, Hash, Ordhash, Array
1735 # iterator ( )
1736  
1737 sub iterator {
1738 2 ▶ my ( $self, @keys ) = @_;
Subroutine iterator: called CC=14 SCAR=38.1
1739  
1740 2 my $pkg = $self->blessed();
1741 2 ▶ my $flg = ($pkg->can('NEXTKEY') || $pkg->can('keys')) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$pkg->can('NEXTKEY') || $pkg->can('keys') ? : 2 0 2
Condition33%1/3
$pkg->can("NEXTKEY") or $pkg->can("keys")
l!l&&r!l&&!r
200
MC/DC0%0/2
$pkg->can("NEXTKEY") or $pkg->can("keys")
$pkg->can("NEXTKEY") $pkg->can("keys")
Truth table33%1/3
A or B
A= $pkg->can("NEXTKEY")B= $pkg->can("keys")
ABresult
1X1
011
000
1742 2 ▶ my $get = $pkg->can('FETCH') ? 'FETCH' : $pkg->can('get') ? 'get' : '';
Branch: 2 branches
BranchTrueFalseTotal
$pkg->can('FETCH') ? : 2 0 2
$pkg->can('get') ? : 0 0 0
1743  
1744 2 ▶ unless ( ($flg || $pkg->can('FETCHSIZE')) && $get ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($flg || $pkg->can("FETCHSIZE") and $get) 0 2 2
Condition33%2/6
$flg || $pkg->can("FETCHSIZE") and $get
!ll&&!rl&&r
002
$flg or $pkg->can("FETCHSIZE")
l!l&&r!l&&!r
200
MC/DC0%0/3
$flg || $pkg->can("FETCHSIZE") and $get
$flg $pkg->can("FETCHSIZE") $get
Truth table20%1/5
A or B and C
A= $flgB= $pkg->can("FETCHSIZE")C= $get
ABCresult
00X0
1X00
0100
1X11
0111
1745 0 ▶ return sub {};
Subroutine __ANON__: not called CC=1 SCAR=6.9
1746 }
1747  
1748 # MCE::Shared::{ Array, Cache, Hash, Ordhash }, Hash::Ordered,
1749 # or similar module.
1750  
1751 2 ▶ $get = 'peek' if $pkg->isa('MCE::Shared::Cache');
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->isa("MCE::Shared::Cache") 2 0 2
1752  
1753 2 ▶ if ( ! @keys ) {
Branch: 3 branches
BranchTrueFalseTotal
if (not @keys) { } 2 0 2
elsif (@keys == 1 and $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/) { } 0 0 0
elsif ($pkg->isa('MCE::Shared::Cache')) { } 0 0 0
1754 2 @keys = $self->keys;
1755 }
1756 ▶ elsif ( @keys == 1 && $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/ ) {
Condition0%0/3
@keys == 1 and $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
!ll&&!rl&&r
000
MC/DC0%0/2
@keys == 1 and $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
@keys == 1 $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
Truth table0%0/3
A and B
A= @keys == 1B= $keys[0] =~ /^(?:key|val)[ ]+\S\S?[ ]+\S/
ABresult
0X0
100
111
1757 0 ▶ return sub {} unless $pkg->isa('MCE::Shared::Common');
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless $pkg->isa("MCE::Shared::Common") 0 0 0
1758 0 @keys = $self->keys($keys[0]);
1759 }
1760 elsif ( $pkg->isa('MCE::Shared::Cache') ) {
1761 0 $self->_prune_head();
1762 }
1763  
1764 return sub {
1765 10 ▶ return unless @keys;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless @keys 2 8 10
1766 8 my $key = shift @keys;
1767 8 return ( $key => $self->$get($key) );
1768 2 };
1769 }
1770  
1771 # rewind ( index [, index, ... ] ) # Array
1772 # rewind ( key [, key, ... ] ) # Cache, Hash, Ordhash
1773 # rewind ( "query string" ) # Cache, Hash, Ordhash, Array
1774 # rewind ( begin, end [, step, format ] ) # Sequence
1775 # rewind ( )
1776  
1777 sub rewind {
1778 18 ▶ my $_id = shift()->[_ID];
Subroutine rewind: called CC=1 SCAR=0.0
1779 18 my $_buf = $_freeze->([ @_ ]);
1780 18 _req1('M~IRW', $_id.$LF . length($_buf).$LF . $_buf);
1781  
1782 18 return;
1783 }
1784  
1785 # next ( )
1786  
1787 sub next {
1788 127 ▶ local $\ = undef if (defined $\);
Subroutine next: called CC=14 SCAR=28.0
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 127 127
1789 127 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 127 127
1790 127 local $MCE::Signal::SIG;
1791  
1792 127 my ( $_len, $_buf );
1793  
1794 {
1795 127 local $MCE::Signal::IPC = 1;
1796 127 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 127 127
1797  
1798 127 print({$_DAT_W_SOCK} 'M~INX'.$LF . $_chn.$LF),
1799 127 print({$_DAU_W_SOCK} $_[0]->[_ID].$LF);
1800 127 chomp($_len = <$_DAU_W_SOCK>);
1801  
1802 127 ▶ read($_DAU_W_SOCK, $_buf, $_len) if ($_len >= 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len >= 0 112 15 127
1803  
1804 127 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 127 0 127
1805 }
1806  
1807 127 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 127 127
1808  
1809 127 ▶ return if ($_len < 0);
Branch: 1 branch
BranchTrueFalseTotal
if $_len < 0 15 112 127
1810  
1811 112 ▶ my $_b; return wantarray ? () : undef unless @{ $_b = $_thaw->($_buf) };
Branch: 2 branches
BranchTrueFalseTotal
unless @{$_b = &$_thaw($_buf);} 7 105 112
wantarray ? : 1 6 7
1812  
1813 105 ▶ if ( $_[0]->[_DECODE] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0][3]) 0 105 105
1814 0 ▶ local $@; $_b->[-1] = eval { $_[0]->[_DECODE]->($_b->[-1]) } || $_b->[-1];
Condition0%0/3
eval { do { $_[0][3]->($_b->[-1]) } } || $_b->[-1]
l!l&&r!l&&!r
000
MC/DC0%0/2
eval { do { $_[0][3]->($_b->[-1]) } } || $_b->[-1]
eval { do { $_[0][3]->($_b->[-1]) } } $_b->[-1]
Truth table0%0/3
A || B
A= eval { do { $_[0][3]->($_b->[-1]) } }B= $_b->[-1]
ABresult
1X1
011
000
1815 }
1816  
1817 ( wantarray )
1818 105 ▶ ? @{ $_b } == 2 ? ( $_b->[0], delete $_b->[-1] ) : @{ $_b }
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 24 81 105
@{$_b;} == 2 ? : 12 12 24
1819 : delete $_b->[-1];
1820 }
1821  
1822 ###############################################################################
1823 ## ----------------------------------------------------------------------------
1824 ## Methods optimized for:
1825 ## MCE::Shared::{ Array, Hash, Ordhash, Scalar } and similar.
1826 ##
1827 ###############################################################################
1828  
1829 sub ins_inplace {
1830 0 ▶ my $_id = shift()->[_ID];
Subroutine ins_inplace: not called CC=2 SCAR=17.9
1831  
1832 0 ▶ if ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
1833 0 my $_tmp = Storable::freeze([ @_ ]);
1834 0 my $_buf = $_id.$LF . length($_tmp).$LF;
1835 0 _req2('O~PDL', $_buf, $_tmp);
1836 }
1837  
1838 0 return;
1839 }
1840  
1841 4 ▶sub FETCHSIZE { _size('FETCHSIZE', @_) }
Subroutine FETCHSIZE: called CC=1 SCAR=0.0
1842 0 ▶sub SCALAR { _size('SCALAR' , @_) }
Subroutine SCALAR: not called CC=1 SCAR=6.9
1843 6 ▶sub CLEAR { _req3('CLEAR' , @_) }
Subroutine CLEAR: called CC=1 SCAR=0.0
1844 98 ▶sub FETCH { _req4('FETCH' , @_) }
Subroutine FETCH: called CC=1 SCAR=0.0
1845  
1846 sub clear {
1847 34 ▶ @_ > 1 ? _auto('clear', @_) : _req3('clear', @_);
Subroutine clear: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
@_ > 1 ? : 0 34 34
1848 }
1849 sub get {
1850 59 ▶ @_ > 2 ? _auto('get', @_) : _req4('get', @_);
Subroutine get: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
@_ > 2 ? : 0 59 59
1851 }
1852  
1853 sub FIRSTKEY {
1854 6 ▶ $_[0]->[_ITER] = [ $_[0]->keys ];
Subroutine FIRSTKEY: called CC=1 SCAR=0.0
1855 6 shift @{ $_[0]->[_ITER] };
1856 }
1857 sub NEXTKEY {
1858 9 ▶ shift @{ $_[0]->[_ITER] };
Subroutine NEXTKEY: called CC=1 SCAR=0.0
1859 }
1860  
1861 sub STORE {
1862 58 ▶ if ( @_ > 1 && $_[0]->[_ENCODE] ) {
Subroutine STORE: called CC=12 SCAR=32.1
Branch: 3 branches
BranchTrueFalseTotal
if (@_ > 1 and $_[0][2]) { } 0 58 58
elsif (@_ == 2 and &$_blessed($_[1]) and $_[1]->can('SHARED_ID')) { } 0 58 58
elsif (ref $_[2]) { } 4 54 58
Condition33%1/3
@_ > 1 and $_[0][2]
!ll&&!rl&&r
0580
MC/DC0%0/2
@_ > 1 and $_[0][2]
@_ > 1 $_[0][2]
Truth table33%1/3
A and B
A= @_ > 1B= $_[0][2]
ABresult
0X0
100
111
1863 0 ▶ $_[-1] = $_[0]->[_ENCODE]->($_[-1]) if ref($_[-1]);
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[-1] 0 0 0
1864 }
1865 ▶ elsif ( @_ == 2 && $_blessed->($_[1]) && $_[1]->can('SHARED_ID') ) {
Condition50%3/6
@_ == 2 and &$_blessed($_[1]) and $_[1]->can("SHARED_ID")
!ll&&!rl&&r
5800
@_ == 2 and &$_blessed($_[1])
!ll&&!rl&&r
32260
MC/DC0%0/3
@_ == 2 and &$_blessed($_[1]) and $_[1]->can("SHARED_ID")
@_ == 2 &$_blessed($_[1]) $_[1]->can("SHARED_ID")
Truth table50%2/4
A and B and C
A= @_ == 2B= &$_blessed($_[1])C= $_[1]->can("SHARED_ID")
ABCresult
0XX0
10X0
1100
1111
1866 0 _req2('M~DEE', $_[0]->[_ID].$LF, $_[1]->SHARED_ID().$LF);
1867 0 delete $_new{ $_[1]->SHARED_ID() };
1868 }
1869 elsif ( ref $_[2] ) {
1870 4 ▶ if ( $_blessed->($_[2]) && $_[2]->can('SHARED_ID') ) {
Branch: 2 branches
BranchTrueFalseTotal
if (&$_blessed($_[2]) and $_[2]->can('SHARED_ID')) { } 0 4 4
elsif ($_[0][1]->isa('MCE::Shared::Array') or $_[0][1]->isa('MCE::Shared::Hash')) { } 2 2 4
Condition33%1/3
&$_blessed($_[2]) and $_[2]->can("SHARED_ID")
!ll&&!rl&&r
400
MC/DC0%0/2
&$_blessed($_[2]) and $_[2]->can("SHARED_ID")
&$_blessed($_[2]) $_[2]->can("SHARED_ID")
Truth table33%1/3
A and B
A= &$_blessed($_[2])B= $_[2]->can("SHARED_ID")
ABresult
0X0
100
111
1871 0 _req2('M~DEE', $_[0]->[_ID].$LF, $_[2]->SHARED_ID().$LF);
1872 0 delete $_new{ $_[2]->SHARED_ID() };
1873 }
1874 ▶ elsif ( $_[0]->[1]->isa('MCE::Shared::Array') ||
Condition100%3/3
$_[0][1]->isa("MCE::Shared::Array") or $_[0][1]->isa("MCE::Shared::Hash")
l!l&&r!l&&!r
112
MC/DC100%2/2
$_[0][1]->isa("MCE::Shared::Array") or $_[0][1]->isa("MCE::Shared::Hash")
$_[0][1]->isa("MCE::Shared::Array") $_[0][1]->isa("MCE::Shared::Hash")
Truth table100%3/3
A or B
A= $_[0][1]->isa("MCE::Shared::Array")B= $_[0][1]->isa("MCE::Shared::Hash")
ABresult
1X1
011
000
1875 $_[0]->[1]->isa('MCE::Shared::Hash') ) {
1876 2 $_[2] = MCE::Shared::share({ _DEEPLY_ => 1 }, $_[2]);
1877 2 _req2('M~DEE', $_[0]->[_ID].$LF, $_[2]->SHARED_ID().$LF);
1878 }
1879 }
1880 58 _auto('STORE', @_); 1;
1881 }
1882  
1883 sub set {
1884 45 ▶ if ( ref $_[2] ) {
Subroutine set: called CC=4 SCAR=23.7
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[2]) 0 45 45
1885 0 ▶ if ( $_blessed->($_[2]) && $_[2]->can('SHARED_ID') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$_blessed($_[2]) and $_[2]->can("SHARED_ID")) 0 0 0
Condition0%0/3
&$_blessed($_[2]) and $_[2]->can("SHARED_ID")
!ll&&!rl&&r
000
MC/DC0%0/2
&$_blessed($_[2]) and $_[2]->can("SHARED_ID")
&$_blessed($_[2]) $_[2]->can("SHARED_ID")
Truth table0%0/3
A and B
A= &$_blessed($_[2])B= $_[2]->can("SHARED_ID")
ABresult
0X0
100
111
1886 0 _req2('M~DEE', $_[0]->[_ID].$LF, $_[2]->SHARED_ID().$LF);
1887 0 delete $_new{ $_[2]->SHARED_ID() };
1888 }
1889 }
1890 45 _auto('set', @_);
1891 }
1892  
1893 sub keys {
1894 145 ▶ ( @_ == 1 && !wantarray ) ? _size('keys', @_) : _auto('keys', @_);
Subroutine keys: called CC=3 SCAR=12.0
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && !wantarray ? : 0 145 145
Condition66%2/3
@_ == 1 and not wantarray
!ll&&!rl&&r
118270
MC/DC0%0/2
@_ == 1 and not wantarray
@_ == 1 not wantarray
Truth table66%2/3
A and not(B)
A= @_ == 1B= not wantarray
ABresult
0X0
100
111
1895 }
1896  
1897 sub lock {
1898 6 ▶ my ( $self ) = @_;
Subroutine lock: called CC=2 SCAR=7.1
1899 6 ▶ Carp::croak( sprintf(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[6] 0 6 6
1900 "Mutex not enabled for the shared %s instance", $self->[_CLASS]
1901 )) unless $self->[_MUTEX];
1902  
1903 6 $self->[_MUTEX]->lock();
1904 }
1905  
1906 sub unlock {
1907 1 ▶ my ( $self ) = @_;
Subroutine unlock: called CC=2 SCAR=7.1
1908 1 ▶ Carp::croak( sprintf(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->[6] 0 1 1
1909 "Mutex not enabled for the shared %s instance", $self->[_CLASS]
1910 )) unless $self->[_MUTEX];
1911  
1912 1 $self->[_MUTEX]->unlock();
1913 }
1914  
1915 {
1916 43 ▶ no strict 'refs'; *{ __PACKAGE__.'::store' } = \&STORE;
Subroutine BEGIN: called CC=1 SCAR=0.0
1917 }
1918  
1919 43 1;
1920  
1921 __END__
↑ Summary Shared/Minidb.pm »