| 1 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 2 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Hybrid-queue helper class. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 5 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | package MCE::Shared::Queue; | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | 8 | ▶ | no warnings qw( threads recursion uninitialized numeric ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 8 | our $VERSION = '1.894'; | |||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | ## no critic (Subroutines::ProhibitExplicitReturnUndef) | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use Scalar::Util qw( looks_like_number ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | ▶ | use MCE::Shared::Base (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | use MCE::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | use MCE::Mutex (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | ▶ | use overload ( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | q("") => \&MCE::Shared::Base::_stringify, | |||||||||||||||||||||||||||||||||||||||||
| 27 | q(0+) => \&MCE::Shared::Base::_numify, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | fallback => 1 | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ## Attributes used internally. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ## _qr_sock _qw_sock _datp _datq _dsem _heap _init_pid _porder _type | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ## _ar_sock _aw_sock _asem _tsem | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | our ($HIGHEST, $LOWEST, $FIFO, $LIFO, $LILO, $FILO) = (1, 0, 1, 0, 1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | my ($PORDER, $TYPE, $AWAIT) = ($HIGHEST, $FIFO, 0); | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 8 | my $LF = "\012"; Internals::SvREADONLY($LF, 1); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 8 | ▶ | my $_tid = $INC{'threads.pm'} ? threads->tid() : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 8 | my $_reset_flg = 1; | |||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 8 | my %_valid_fields_new = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 47 | await barrier fast porder queue type | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub _croak { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_croak: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | goto &MCE::Shared::Base::_croak; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub CLONE { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $_tid = threads->tid() if $INC{'threads.pm'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 26 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 26 | my ($_Q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 26 | ▶ | my $_pid = $_tid ? $$ .'.'. $_tid : $$; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 26 | undef $_Q->{_datp}, undef $_Q->{_datq}, undef $_Q->{_heap}; | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 26 | ▶ | if ($_Q->{_init_pid} eq $_pid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 26 | MCE::Util::_destroy_socks($_Q, qw(_aw_sock _ar_sock _qw_sock _qr_sock)); | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 71 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 72 | ## Instance instantiation. | ||||||||||||||||||||||||||||||||||||||||||
| 73 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 74 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # new ( options ) | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 26 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=28.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 26 | my ($_class, %_argv) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 26 | ▶ | my $_Q = {}; bless($_Q, ref($_class) || $_class); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $_class || $_class
MC/DC0%0/2
ref $_class || $_class
ref $_class
$_class
Truth table33%1/3
A || B
A= ref $_classB= $_class
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 26 | for my $_p (keys %_argv) { | |||||||||||||||||||||||||||||||||||||||||
| 83 | _croak("Queue: ($_p) is not a valid constructor argument") | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 36 | ▶ | unless (exists $_valid_fields_new{$_p}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 26 | $_Q->{_asem} = 0; # Semaphore count variable for the ->await method | |||||||||||||||||||||||||||||||||||||||||
| 88 | 26 | $_Q->{_datp} = {}; # Priority data { p1 => [ ], p2 => [ ], pN => [ ] } | |||||||||||||||||||||||||||||||||||||||||
| 89 | 26 | $_Q->{_heap} = []; # Priority heap [ pN, p2, p1 ] in heap order | |||||||||||||||||||||||||||||||||||||||||
| 90 | # fyi, _datp will always dequeue before _datq | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | # -------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 26 | ▶ | $_Q->{_await} = defined $_argv{await} ? $_argv{await} : $AWAIT; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 26 | ▶ | $_Q->{_porder} = defined $_argv{porder} ? $_argv{porder} : $PORDER; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 26 | ▶ | $_Q->{_type} = defined $_argv{type} ? $_argv{type} : $TYPE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 26 | ▶ | if (exists $_argv{queue}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | _croak('Queue: (queue) is not an ARRAY reference') | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (ref $_argv{queue} ne 'ARRAY'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $_Q->{_datq} = $_argv{queue}; | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 26 | $_Q->{_datq} = []; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # -------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 26 | $_Q->{_qr_mutex} = MCE::Mutex->new(); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 26 | ▶ | $_Q->{_init_pid} = $_tid ? $$ .'.'. $_tid : $$; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 26 | $_Q->{_dsem} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 26 | MCE::Util::_sock_pair($_Q, qw(_qr_sock _qw_sock), undef, 1); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 26 | ▶ | MCE::Util::_sock_pair($_Q, qw(_ar_sock _aw_sock), undef, 1) if $_Q->{_await}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | MCE::Shared::Object::_reset(), $_reset_flg = '' | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 26 | ▶ | if ($_reset_flg && $INC{'MCE/Shared/Server.pm'}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_reset_flg and $INC{"MCE/Shared/Server.pm"}
MC/DC50%1/2
$_reset_flg and $INC{"MCE/Shared/Server.pm"}
$_reset_flg
$INC{"MCE/Shared/Server.pm"}
Truth table66%2/3
A and B
A= $_reset_flgB= $INC{"MCE/Shared/Server.pm"}
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 26 | return $_Q; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 123 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ## Public methods. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 126 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # await ( pending_threshold ) | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub await { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
await: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | # Handled by MCE::Shared::Object when shared. | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | # clear ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my ($_Q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | %{ $_Q->{_datp} } = (); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | @{ $_Q->{_datq} } = (); | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | @{ $_Q->{_heap} } = (); | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | # end ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub end { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my ($_Q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (!exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | for my $_i (1 .. $_Q->{_dsem}) { syswrite($_Q->{_qw_sock}, $LF) } | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $_Q->{_dsem} = 0, $_Q->{_ended} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | # enqueue ( item [, item, ... ] ) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | sub enqueue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueue: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my $_Q = shift; | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | return unless (scalar @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | warn "Queue: (enqueue) called on queue that has been 'end'ed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($_Q->{_dsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | for my $_i (1 .. scalar @_) { | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $_Q->{_dsem} -= 1, syswrite($_Q->{_qw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | last unless $_Q->{_dsem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | push @{ $_Q->{_datq} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | # enqueuep ( priority, item [, item, ... ] ) | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub enqueuep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
enqueuep: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my ($_Q, $_p) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | _croak('Queue: (enqueuep priority) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_p) or int $_p != $_p
MC/DC0%0/2
not &looks_like_number($_p) or int $_p != $_p
not &looks_like_number($_p)
int $_p != $_p
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_p)B= int $_p != $_p
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | if (!looks_like_number($_p) || int($_p) != $_p); | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return unless (scalar @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if (exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | warn "Queue: (enqueuep) called on queue that has been 'end'ed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | if ($_Q->{_dsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | for my $_i (1 .. scalar @_) { | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $_Q->{_dsem} -= 1, syswrite($_Q->{_qw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | last unless $_Q->{_dsem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $_Q->_enqueuep($_p, @_); | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | # dequeue ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 212 | # dequeue ( count ) | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | sub dequeue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my ($_Q, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my (@_items, $_has_data, $_buf); | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_cnt and $_cnt ne 1
MC/DC0%0/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table0%0/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | _croak('Queue: (dequeue count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table0%0/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ($_pending < $_cnt && scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
MC/DC0%0/1
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
$_pending < $_cnt
Truth table0%0/2
A
A= $_pending < $_cnt
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $_cnt = $_pending if $_pending < $_cnt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | for my $_i (1 .. $_cnt) { push @_items, $_Q->_dequeue() } | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $_has_data = ( @{ $_Q->{_datq} } || @{ $_Q->{_heap} } ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$_Q->{"_datq"};} or @{$_Q->{"_heap"};}
MC/DC0%0/2
@{$_Q->{"_datq"};} or @{$_Q->{"_heap"};}
@{$_Q->{"_datq"};}
@{$_Q->{"_heap"};}
Truth table0%0/3
A or B
A= @{$_Q->{"_datq"};}B= @{$_Q->{"_heap"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $_buf = $_Q->_dequeue(); | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | return @_items if (scalar @_items); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | return $_buf if ($_has_data); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | return () if (exists $_Q->{_ended}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $_Q->{_dsem} += 1, MCE::Util::_sysread($_Q->{_qr_sock}, my($_next), 1); | |||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | goto \&dequeue; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | # dequeue_nb ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 248 | # dequeue_nb ( count ) | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub dequeue_nb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_nb: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my ($_Q, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_cnt and $_cnt ne 1
MC/DC0%0/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table0%0/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | _croak('Queue: (dequeue_nb count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table0%0/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($_pending < $_cnt && scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
MC/DC0%0/1
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
$_pending < $_cnt
Truth table0%0/2
A
A= $_pending < $_cnt
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | $_cnt = $_pending if $_pending < $_cnt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return map { $_Q->_dequeue() } 1 .. $_cnt; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | my $_buf = $_Q->_dequeue(); | |||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return defined($_buf) ? $_buf : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | # dequeue_timed ( timeout ) | ||||||||||||||||||||||||||||||||||||||||||
| 276 | # dequeue_timed ( timeout, count ) | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | sub dequeue_timed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_timed: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my ($_Q, $_timeout, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if (defined $_timeout) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | _croak('Queue: (dequeue_timed timeout argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | if (!looks_like_number($_timeout)); | ||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_cnt and $_cnt ne 1
MC/DC0%0/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table0%0/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | _croak('Queue: (dequeue_timed count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table0%0/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | if ($_pending < $_cnt && scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
MC/DC0%0/1
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
$_pending < $_cnt
Truth table0%0/2
A
A= $_pending < $_cnt
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | $_cnt = $_pending if $_pending < $_cnt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return map { $_Q->_dequeue() } 1 .. $_cnt; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $_buf = $_Q->_dequeue(); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | return defined($_buf) ? $_buf : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | # pending ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | sub pending { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my ($_Q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if (scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | return (exists $_Q->{_ended}) | ||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | ? $_pending ? $_pending : undef | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | : $_pending; | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | # insert ( index, item [, item, ... ] ) | ||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | sub insert { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insert: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my ($_Q, $_i) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | _croak('Queue: (insert index) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_i) or int $_i != $_i
MC/DC0%0/2
not &looks_like_number($_i) or int $_i != $_i
not &looks_like_number($_i)
int $_i != $_i
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_i)B= int $_i != $_i
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | if (!looks_like_number($_i) || int($_i) != $_i); | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | return unless (scalar @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if (exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | warn "Queue: (insert) called on queue that has been 'end'ed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ($_Q->{_dsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | for my $_i (1 .. scalar @_) { | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $_Q->{_dsem} -= 1, syswrite($_Q->{_qw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | last unless $_Q->{_dsem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if (abs($_i) > scalar @{ $_Q->{_datq} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | if ($_i >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ($_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | push @{ $_Q->{_datq} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | unshift @{ $_Q->{_datq} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ($_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | unshift @{ $_Q->{_datq} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | push @{ $_Q->{_datq} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if (!$_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | $_i = ($_i >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | ? scalar(@{ $_Q->{_datq} }) - $_i | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | : abs($_i); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | splice @{ $_Q->{_datq} }, $_i, 0, @_; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | # insertp ( priority, index, item [, item, ... ] ) | ||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub insertp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
insertp: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my ($_Q, $_p, $_i) = (shift, shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | _croak('Queue: (insertp priority) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_p) or int $_p != $_p
MC/DC0%0/2
not &looks_like_number($_p) or int $_p != $_p
not &looks_like_number($_p)
int $_p != $_p
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_p)B= int $_p != $_p
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | if (!looks_like_number($_p) || int($_p) != $_p); | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | _croak('Queue: (insertp index) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_i) or int $_i != $_i
MC/DC0%0/2
not &looks_like_number($_i) or int $_i != $_i
not &looks_like_number($_i)
int $_i != $_i
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_i)B= int $_i != $_i
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | if (!looks_like_number($_i) || int($_i) != $_i); | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | return unless (scalar @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | if (exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | warn "Queue: (insertp) called on queue that has been 'end'ed\n"; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | if ($_Q->{_dsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | for my $_i (1 .. scalar @_) { | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $_Q->{_dsem} -= 1, syswrite($_Q->{_qw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | last unless $_Q->{_dsem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if (exists $_Q->{_datp}->{$_p} && scalar @{ $_Q->{_datp}->{$_p} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
exists $_Q->{"_datp"}{$_p} and scalar @{$_Q->{"_datp"}{$_p};}
MC/DC0%0/1
exists $_Q->{"_datp"}{$_p} and scalar @{$_Q->{"_datp"}{$_p};}
exists $_Q->{"_datp"}{$_p}
Truth table0%0/2
A
A= exists $_Q->{"_datp"}{$_p}
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | if (abs($_i) > scalar @{ $_Q->{_datp}->{$_p} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($_i >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ($_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | push @{ $_Q->{_datp}->{$_p} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | unshift @{ $_Q->{_datp}->{$_p} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||
| 409 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | if ($_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | unshift @{ $_Q->{_datp}->{$_p} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 412 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | push @{ $_Q->{_datp}->{$_p} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if (!$_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | $_i = ($_i >=0) | ||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | ? scalar(@{ $_Q->{_datp}->{$_p} }) - $_i | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 421 | : abs($_i); | ||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | splice @{ $_Q->{_datp}->{$_p} }, $_i, 0, @_; | |||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $_Q->_enqueuep($_p, @_); | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | # peek ( index ) | ||||||||||||||||||||||||||||||||||||||||||
| 434 | # peek ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub peek { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peek: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my ($_Q, $_i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ($_i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | _croak('Queue: (peek index) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_i) or int $_i != $_i
MC/DC0%0/2
not &looks_like_number($_i) or int $_i != $_i
not &looks_like_number($_i)
int $_i != $_i
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_i)B= int $_i != $_i
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | if (!looks_like_number($_i) || int($_i) != $_i); | ||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | else { $_i = 0 } | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | return undef if (abs($_i) > scalar @{ $_Q->{_datq} }); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if (!$_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | $_i = ($_i >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | ? scalar(@{ $_Q->{_datq} }) - ($_i + 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | : abs($_i + 1); | ||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return $_Q->{_datq}->[$_i]; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | # peekp ( priority, index ) | ||||||||||||||||||||||||||||||||||||||||||
| 457 | # peekp ( priority ) | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | sub peekp { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peekp: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my ($_Q, $_p, $_i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ($_i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | _croak('Queue: (peekp index) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_i) or int $_i != $_i
MC/DC0%0/2
not &looks_like_number($_i) or int $_i != $_i
not &looks_like_number($_i)
int $_i != $_i
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_i)B= int $_i != $_i
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | if (!looks_like_number($_i) || int($_i) != $_i); | ||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | else { $_i = 0 } | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | _croak('Queue: (peekp priority) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_p) or int $_p != $_p
MC/DC0%0/2
not &looks_like_number($_p) or int $_p != $_p
not &looks_like_number($_p)
int $_p != $_p
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_p)B= int $_p != $_p
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | if (!looks_like_number($_p) || int($_p) != $_p); | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | return undef unless (exists $_Q->{_datp}->{$_p}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | return undef if (abs($_i) > scalar @{ $_Q->{_datp}->{$_p} }); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if (!$_Q->{_type}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | $_i = ($_i >= 0) | ||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | ? scalar(@{ $_Q->{_datp}->{$_p} }) - ($_i + 1) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 477 | : abs($_i + 1); | ||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return $_Q->{_datp}->{$_p}->[$_i]; | |||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | # peekh ( index ) | ||||||||||||||||||||||||||||||||||||||||||
| 484 | # peekh ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub peekh { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peekh: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my ($_Q, $_i) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if ($_i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | _croak('Queue: (peekh index) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_i) or int $_i != $_i
MC/DC0%0/2
not &looks_like_number($_i) or int $_i != $_i
not &looks_like_number($_i)
int $_i != $_i
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_i)B= int $_i != $_i
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | if (!looks_like_number($_i) || int($_i) != $_i); | ||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | else { $_i = 0 } | |||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | ▶ | return undef if (abs($_i) > scalar @{ $_Q->{_heap} }); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return $_Q->{_heap}->[$_i]; | |||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | # heap ( ) | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | sub heap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
heap: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | return @{ shift->{_heap} }; | |||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 506 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 507 | ## Private methods. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 509 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | # Add items to the tail of the queue with priority level. | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | sub _enqueuep { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_enqueuep: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my ($_Q, $_p) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | # Enlist priority into the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if (!exists $_Q->{_datp}->{$_p} || @{ $_Q->{_datp}->{$_p} } == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not exists $_Q->{"_datp"}{$_p} or @{$_Q->{"_datp"}{$_p};} == 0
MC/DC0%0/2
not exists $_Q->{"_datp"}{$_p} or @{$_Q->{"_datp"}{$_p};} == 0
not exists $_Q->{"_datp"}{$_p}
@{$_Q->{"_datp"}{$_p};} == 0
Truth table0%0/3
not(A) or B
A= not exists $_Q->{"_datp"}{$_p}B= @{$_Q->{"_datp"}{$_p};} == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | unless (scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | push @{ $_Q->{_heap} }, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | elsif ($_Q->{_porder}) { | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $_Q->_heap_insert_high($_p); | |||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||
| 525 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $_Q->_heap_insert_low($_p); | |||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||
| 530 | # Append item(s) into the queue. | ||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | push @{ $_Q->{_datp}->{$_p} }, @_; | |||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | # Return one item from the queue. | ||||||||||||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | sub _dequeue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dequeue: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my ($_Q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # Return item from the non-priority queue. | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | unless (scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 543 | return ($_Q->{_type}) | ||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | ? shift @{ $_Q->{_datq} } : pop @{ $_Q->{_datq} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my $_p = $_Q->{_heap}->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | # Delist priority from the heap when 1 item remains. | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | shift @{ $_Q->{_heap} } if (@{ $_Q->{_datp}->{$_p} } == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | # Return item from the priority queue. | ||||||||||||||||||||||||||||||||||||||||||
| 553 | return ($_Q->{_type}) | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | ? shift @{ $_Q->{_datp}->{$_p} } : pop @{ $_Q->{_datp}->{$_p} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | # Helper method for getting the reference to the underlying array. | ||||||||||||||||||||||||||||||||||||||||||
| 558 | # Use with test scripts for comparing data only (not a public API). | ||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | sub _get_aref { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_aref: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | my ($_Q, $_p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | if (defined $_p) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | _croak('Queue: (get_aref priority) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_p) or int $_p != $_p
MC/DC0%0/2
not &looks_like_number($_p) or int $_p != $_p
not &looks_like_number($_p)
int $_p != $_p
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_p)B= int $_p != $_p
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | if (!looks_like_number($_p) || int($_p) != $_p); | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | return undef unless (exists $_Q->{_datp}->{$_p}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | return $_Q->{_datp}->{$_p}; | |||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | return $_Q->{_datq}; | |||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | # Insert priority into the heap. A lower priority level comes first. | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub _heap_insert_low { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_heap_insert_low: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my ($_Q, $_p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | # Insert priority at the head of the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if ($_p < $_Q->{_heap}->[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | unshift @{ $_Q->{_heap} }, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | # Insert priority at the end of the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 585 | elsif ($_p > $_Q->{_heap}->[-1]) { | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | push @{ $_Q->{_heap} }, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||
| 589 | # Insert priority through binary search. | ||||||||||||||||||||||||||||||||||||||||||
| 590 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | my $_lower = 0; my $_upper = @{ $_Q->{_heap} }; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | while ($_lower < $_upper) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my $_midpoint = $_lower + (($_upper - $_lower) >> 1); | |||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | if ($_p > $_Q->{_heap}->[$_midpoint]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | $_lower = $_midpoint + 1; | |||||||||||||||||||||||||||||||||||||||||
| 597 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $_upper = $_midpoint; | |||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||
| 602 | # Insert priority into the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | splice @{ $_Q->{_heap} }, $_lower, 0, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | # Insert priority into the heap. A higher priority level comes first. | ||||||||||||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | sub _heap_insert_high { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_heap_insert_high: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my ($_Q, $_p) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||
| 614 | # Insert priority at the head of the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | ▶ | if ($_p > $_Q->{_heap}->[0]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | unshift @{ $_Q->{_heap} }, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | # Insert priority at the end of the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 620 | elsif ($_p < $_Q->{_heap}->[-1]) { | ||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | push @{ $_Q->{_heap} }, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | # Insert priority through binary search. | ||||||||||||||||||||||||||||||||||||||||||
| 625 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | my $_lower = 0; my $_upper = @{ $_Q->{_heap} }; | |||||||||||||||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | ▶ | while ($_lower < $_upper) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | my $_midpoint = $_lower + (($_upper - $_lower) >> 1); | |||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | if ($_p < $_Q->{_heap}->[$_midpoint]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | $_lower = $_midpoint + 1; | |||||||||||||||||||||||||||||||||||||||||
| 632 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | $_upper = $_midpoint; | |||||||||||||||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||||||||||||||
| 635 | } | ||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | # Insert priority into the heap. | ||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | splice @{ $_Q->{_heap} }, $_lower, 0, $_p; | |||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 645 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 646 | ## Server functions. | ||||||||||||||||||||||||||||||||||||||||||
| 647 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 648 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | { | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 8 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||
| 653 | 8 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 654 | 8 | SHR_O_QUA => 'O~QUA', # Queue await | |||||||||||||||||||||||||||||||||||||||||
| 655 | SHR_O_QUD => 'O~QUD', # Queue dequeue | ||||||||||||||||||||||||||||||||||||||||||
| 656 | SHR_O_QUN => 'O~QUN', # Queue dequeue non-blocking | ||||||||||||||||||||||||||||||||||||||||||
| 657 | SHR_O_QUT => 'O~QUT', # Queue dequeue timed | ||||||||||||||||||||||||||||||||||||||||||
| 658 | 8 | }; | |||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||
| 660 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 661 | 8 | $_DAU_R_SOCK_REF, $_DAU_R_SOCK, $_obj, $_freeze, $_thaw, | |||||||||||||||||||||||||||||||||||||||||
| 662 | $_cnt, $_id, $_has_data, $_pending, $_t | ||||||||||||||||||||||||||||||||||||||||||
| 663 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||
| 665 | my %_output_function = ( | ||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | SHR_O_QUA.$LF => sub { # Queue await | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF }; | |||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | chomp($_id = <$_DAU_R_SOCK>), | |||||||||||||||||||||||||||||||||||||||||
| 671 | chomp($_t = <$_DAU_R_SOCK>); | ||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | my $_Q = $_obj->{ $_id } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} $LF;
return
}
MC/DC0%0/2
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} $LF;
return
}
$_obj->{$_id}
do {
print {$_DAU_R_SOCK;} $LF;
return
}
Truth table0%0/3
A || B
A= $_obj->{$_id}B= do {
print {$_DAU_R_SOCK;} $LF;
return
}
| |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | print {$_DAU_R_SOCK} $LF; | |||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 676 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | $_Q->{_tsem} = $_t; | |||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | if ($_Q->pending() <= $_t) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | syswrite($_Q->{_aw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 681 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | $_Q->{_asem} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | print {$_DAU_R_SOCK} $LF; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 688 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | SHR_O_QUD.$LF => sub { # Queue dequeue | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=18 SCAR=58.3
| |||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF }; | |||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | chomp($_id = <$_DAU_R_SOCK>), | |||||||||||||||||||||||||||||||||||||||||
| 694 | chomp($_cnt = <$_DAU_R_SOCK>); | ||||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | $_cnt = 0 if ($_cnt == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | my $_Q = $_obj->{ $_id } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
MC/DC0%0/2
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
$_obj->{$_id}
do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
Truth table0%0/3
A || B
A= $_obj->{$_id}B= do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
| |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | print {$_DAU_R_SOCK} '-1'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 701 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my (@_items, $_buf); | |||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if ($_cnt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | ▶ | if ($_pending < $_cnt && scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
MC/DC0%0/1
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
$_pending < $_cnt
Truth table0%0/2
A
A= $_pending < $_cnt
| |||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||||||||||||||||
| 712 | } | ||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | ▶ | $_cnt = $_pending if $_pending < $_cnt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | for my $_i (1 .. $_cnt) { push @_items, $_Q->_dequeue() } | |||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||
| 717 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | $_has_data = ( @{ $_Q->{_datq} } || @{ $_Q->{_heap} } ) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@{$_Q->{"_datq"};} or @{$_Q->{"_heap"};}
MC/DC0%0/2
@{$_Q->{"_datq"};} or @{$_Q->{"_heap"};}
@{$_Q->{"_datq"};}
@{$_Q->{"_heap"};}
Truth table0%0/3
A or B
A= @{$_Q->{"_datq"};}B= @{$_Q->{"_heap"};}
| |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | $_buf = $_Q->_dequeue(); | |||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if ($_cnt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | $_buf = $_freeze->(\@_items); | |||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | print {$_DAU_R_SOCK} length($_buf).$LF, $_buf; | |||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||
| 726 | elsif ($_has_data) { | ||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $_buf = $_freeze->([ $_buf ]); | |||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | print {$_DAU_R_SOCK} length($_buf).$LF, $_buf; | |||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||
| 730 | elsif (exists $_Q->{_ended}) { | ||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | print {$_DAU_R_SOCK} '-2'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||
| 733 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | print {$_DAU_R_SOCK} '-1'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $_Q->{_dsem} += 1; | |||||||||||||||||||||||||||||||||||||||||
| 736 | } | ||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if ($_Q->{_await} && $_Q->{_asem} && $_Q->pending() <= $_Q->{_tsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$_Q->{"_await"} and $_Q->{"_asem"} and $_Q->pending <= $_Q->{"_tsem"}
$_Q->{"_await"} and $_Q->{"_asem"}
MC/DC0%0/3
$_Q->{"_await"} and $_Q->{"_asem"} and $_Q->pending <= $_Q->{"_tsem"}
$_Q->{"_await"}
$_Q->{"_asem"}
$_Q->pending <= $_Q->{"_tsem"}
Truth table0%0/4
A and B and C
A= $_Q->{"_await"}B= $_Q->{"_asem"}C= $_Q->pending <= $_Q->{"_tsem"}
| |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | for my $_i (1 .. $_Q->{_asem}) { | |||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | syswrite($_Q->{_aw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $_Q->{_asem} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 746 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | ▶ | SHR_O_QUN.$LF => sub { # Queue dequeue non-blocking | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF }; | |||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | chomp($_id = <$_DAU_R_SOCK>), | |||||||||||||||||||||||||||||||||||||||||
| 752 | chomp($_cnt = <$_DAU_R_SOCK>); | ||||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | ▶ | my $_Q = $_obj->{ $_id } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
MC/DC0%0/2
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
$_obj->{$_id}
do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
Truth table0%0/3
A || B
A= $_obj->{$_id}B= do {
print {$_DAU_R_SOCK;} '-1' . $LF;
return
}
| |||||||||||||||||||||||||||||||||||||||||||
| 755 | 0 | print {$_DAU_R_SOCK} '-1'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 757 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if ($_cnt == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | my $_buf = $_Q->_dequeue(); | |||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | ▶ | if (defined $_buf) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | $_buf = $_freeze->([ $_buf ]); | |||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | print {$_DAU_R_SOCK} length($_buf).$LF, $_buf; | |||||||||||||||||||||||||||||||||||||||||
| 765 | } | ||||||||||||||||||||||||||||||||||||||||||
| 766 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | print {$_DAU_R_SOCK} '-1'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 768 | } | ||||||||||||||||||||||||||||||||||||||||||
| 769 | } | ||||||||||||||||||||||||||||||||||||||||||
| 770 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | my @_items; | |||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | my $_pending = @{ $_Q->{_datq} }; | |||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | if ($_pending < $_cnt && scalar @{ $_Q->{_heap} }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
MC/DC0%0/1
$_pending < $_cnt and scalar @{$_Q->{"_heap"};}
$_pending < $_cnt
Truth table0%0/2
A
A= $_pending < $_cnt
| |||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | for my $_h (@{ $_Q->{_heap} }) { | |||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | $_pending += @{ $_Q->{_datp}->{$_h} }; | |||||||||||||||||||||||||||||||||||||||||
| 777 | } | ||||||||||||||||||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | $_cnt = $_pending if $_pending < $_cnt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | for my $_i (1 .. $_cnt) { push @_items, $_Q->_dequeue() } | |||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ▶ | if ($_cnt) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | my $_buf = $_freeze->(\@_items); | |||||||||||||||||||||||||||||||||||||||||
| 785 | 0 | print {$_DAU_R_SOCK} length($_buf).$LF, $_buf; | |||||||||||||||||||||||||||||||||||||||||
| 786 | } | ||||||||||||||||||||||||||||||||||||||||||
| 787 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | print {$_DAU_R_SOCK} '-1'.$LF; | |||||||||||||||||||||||||||||||||||||||||
| 789 | } | ||||||||||||||||||||||||||||||||||||||||||
| 790 | } | ||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||
| 792 | 0 | ▶ | if ($_Q->{_await} && $_Q->{_asem} && $_Q->pending() <= $_Q->{_tsem}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$_Q->{"_await"} and $_Q->{"_asem"} and $_Q->pending <= $_Q->{"_tsem"}
$_Q->{"_await"} and $_Q->{"_asem"}
MC/DC0%0/3
$_Q->{"_await"} and $_Q->{"_asem"} and $_Q->pending <= $_Q->{"_tsem"}
$_Q->{"_await"}
$_Q->{"_asem"}
$_Q->pending <= $_Q->{"_tsem"}
Truth table0%0/4
A and B and C
A= $_Q->{"_await"}B= $_Q->{"_asem"}C= $_Q->pending <= $_Q->{"_tsem"}
| |||||||||||||||||||||||||||||||||||||||||||
| 793 | 0 | for my $_i (1 .. $_Q->{_asem}) { | |||||||||||||||||||||||||||||||||||||||||
| 794 | 0 | syswrite($_Q->{_aw_sock}, $LF); | |||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | $_Q->{_asem} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 800 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | ▶ | SHR_O_QUT.$LF => sub { # Queue dequeue timed | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF }; | |||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | chomp($_id = <$_DAU_R_SOCK>); | |||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | ▶ | my $_Q = $_obj->{ $_id } || do { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} $LF;
return
}
MC/DC0%0/2
$_obj->{$_id} || do {
print {$_DAU_R_SOCK;} $LF;
return
}
$_obj->{$_id}
do {
print {$_DAU_R_SOCK;} $LF;
return
}
Truth table0%0/3
A || B
A= $_obj->{$_id}B= do {
print {$_DAU_R_SOCK;} $LF;
return
}
| |||||||||||||||||||||||||||||||||||||||||||
| 808 | 0 | print {$_DAU_R_SOCK} $LF; | |||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 810 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | ▶ | $_Q->{_dsem} -= 1 if $_Q->{_dsem}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | print {$_DAU_R_SOCK} $LF; | |||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 817 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | sub _init_mgr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_mgr: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 822 | 0 | my $_function; | |||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ( $_DAU_R_SOCK_REF, $_obj, $_function, $_freeze, $_thaw ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | for my $key ( keys %_output_function ) { | |||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | last if exists($_function->{$key}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | $_function->{$key} = $_output_function{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 828 | } | ||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 831 | } | ||||||||||||||||||||||||||||||||||||||||||
| 832 | } | ||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||
| 834 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 835 | ## ---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 836 | ## Object package. | ||||||||||||||||||||||||||||||||||||||||||
| 837 | ## | ||||||||||||||||||||||||||||||||||||||||||
| 838 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | ## Items below are folded into MCE::Shared::Object. | ||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||
| 842 | package # hide from rpm | ||||||||||||||||||||||||||||||||||||||||||
| 843 | 8 | MCE::Shared::Object; | |||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 846 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 8 | ▶ | no warnings qw( threads recursion uninitialized numeric once ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||
| 850 | 8 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||
| 852 | 8 | ▶ | no overloading; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||
| 854 | 8 | ▶ | my $_is_MSWin32 = ($^O eq 'MSWin32') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||
| 856 | 8 | my ($_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, $_obj, | |||||||||||||||||||||||||||||||||||||||||
| 857 | $_freeze, $_thaw); | ||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||
| 859 | 22 | ▶ | sub _init_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_queue: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 860 | 22 | ($_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, $_obj, | |||||||||||||||||||||||||||||||||||||||||
| 861 | $_freeze, $_thaw) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||
| 863 | 22 | return; | |||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||
| 866 | 24 | ▶ | sub _req_queue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_req_queue: called CC=7 SCAR=20.4
| |||||||||||||||||||||||||||||||||||||||||||
| 867 | 24 | ▶ | local $\ = undef if (defined $\); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 868 | 24 | ▶ | local $/ = $LF if ($/ ne $LF); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 869 | 24 | local $MCE::Signal::SIG; | |||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||
| 871 | { | ||||||||||||||||||||||||||||||||||||||||||
| 872 | 24 | local $MCE::Signal::IPC = 1; | |||||||||||||||||||||||||||||||||||||||||
| 873 | 24 | ▶ | $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||
| 875 | 24 | print({$_DAT_W_SOCK} $_[0].$LF . $_chn.$LF), | |||||||||||||||||||||||||||||||||||||||||
| 876 | 24 | print({$_DAU_W_SOCK} $_[1]); | |||||||||||||||||||||||||||||||||||||||||
| 877 | 24 | chomp($_[2] = <$_DAU_W_SOCK>); | |||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||
| 879 | 24 | ▶ | read($_DAU_W_SOCK, $_[3], $_[2]) if ($_[2] > 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | 24 | ▶ | $_dat_un->() if !$_is_MSWin32; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 882 | } | ||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||
| 884 | 24 | ▶ | CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 885 | } | ||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | ▶ | sub await { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
await: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | my $_id = shift()->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | return unless ( my $_Q = $_obj->{ $_id } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 890 | 0 | ▶ | return unless ( exists $_Q->{_qr_sock} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | ▶ | my $_t = shift || 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||
| 894 | _croak('Queue: (await) is not enabled for this queue') | ||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | ▶ | unless (exists $_Q->{_ar_sock}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | _croak('Queue: (await threshold) is not an integer') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_t) or int $_t != $_t
MC/DC0%0/2
not &looks_like_number($_t) or int $_t != $_t
not &looks_like_number($_t)
int $_t != $_t
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_t)B= int $_t != $_t
| |||||||||||||||||||||||||||||||||||||||||||
| 897 | if (!looks_like_number($_t) || int($_t) != $_t); | ||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | ▶ | $_t = 0 if ($_t < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | _req1('O~QUA', $_id.$LF . $_t.$LF); | |||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | MCE::Util::_sock_ready($_Q->{_ar_sock}) if $_is_MSWin32; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | MCE::Util::_sysread($_Q->{_ar_sock}, my($_b), 1); | |||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 906 | } | ||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||
| 908 | 16 | ▶ | sub dequeue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue: called CC=13 SCAR=31.5
| |||||||||||||||||||||||||||||||||||||||||||
| 909 | 16 | my ($self, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 910 | 16 | my $_id = $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | 16 | ▶ | return unless ( my $_Q = $_obj->{ $_id } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 913 | 16 | ▶ | return unless ( exists $_Q->{_qr_sock} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | 16 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_cnt and $_cnt ne 1
MC/DC100%2/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table100%3/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 916 | 6 | ▶ | _croak('Queue: (dequeue count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table25%1/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 917 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 918 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 919 | 10 | $_cnt = 1; | |||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | 16 | _req_queue('O~QUD', $_id.$LF . $_cnt.$LF, my($_len), my($_buf)); | |||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||
| 924 | 16 | ▶ | return $_thaw->($_buf)[0] if ($_len > 0 && $_cnt == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_len > 0 and $_cnt == 1
MC/DC50%1/2
$_len > 0 and $_cnt == 1
$_len > 0
$_cnt == 1
Truth table66%2/3
A and B
A= $_len > 0B= $_cnt == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 925 | 6 | ▶ | return @{ $_thaw->($_buf) } if ($_len > 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | return if ($_len == -2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | MCE::Util::_sock_ready($_Q->{_qr_sock}) if $_is_MSWin32; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 929 | 0 | MCE::Util::_sysread($_Q->{_qr_sock}, my($_next), 1); | |||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | goto \&dequeue; | |||||||||||||||||||||||||||||||||||||||||
| 932 | } | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | 4 | ▶ | sub dequeue_nb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_nb: called CC=10 SCAR=32.2
| |||||||||||||||||||||||||||||||||||||||||||
| 935 | 4 | my ($self, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 936 | 4 | my $_id = $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||
| 938 | 4 | ▶ | return unless ( my $_Q = $_obj->{ $_id } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 939 | 4 | ▶ | return unless ( exists $_Q->{_qr_sock} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | 4 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_cnt and $_cnt ne 1
MC/DC0%0/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table33%1/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | _croak('Queue: (dequeue_nb count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table0%0/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 943 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 944 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 945 | 4 | $_cnt = 1; | |||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||
| 948 | 4 | _req_queue('O~QUN', $_id.$LF . $_cnt.$LF, my($_len), my($_buf)); | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | 4 | ▶ | return if ($_len < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | ($_cnt == 1) ? $_thaw->($_buf)[0] : @{ $_thaw->($_buf) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||
| 955 | 4 | ▶ | sub dequeue_timed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dequeue_timed: called CC=23 SCAR=55.3
| |||||||||||||||||||||||||||||||||||||||||||
| 956 | 4 | my ($self, $_timeout, $_cnt) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 957 | 4 | my $_id = $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 958 | 4 | my $_start; | |||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 4 | ▶ | return unless ( my $_Q = $_obj->{ $_id } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 961 | 4 | ▶ | return unless ( exists $_Q->{_qr_sock} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 4 | ▶ | if (defined $_timeout) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | _croak('Queue: (dequeue_timed timeout argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not &looks_like_number($_timeout) or $_timeout < 0
MC/DC0%0/2
not &looks_like_number($_timeout) or $_timeout < 0
not &looks_like_number($_timeout)
$_timeout < 0
Truth table0%0/3
not(A) or B
A= not &looks_like_number($_timeout)B= $_timeout < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 965 | if (!looks_like_number($_timeout) || $_timeout < 0); | ||||||||||||||||||||||||||||||||||||||||||
| 966 | 0 | $_start = MCE::Util::_time(); | |||||||||||||||||||||||||||||||||||||||||
| 967 | } | ||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||
| 969 | 4 | ▶ | if (defined $_cnt && $_cnt ne '1') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_cnt and $_cnt ne 1
MC/DC0%0/2
defined $_cnt and $_cnt ne 1
defined $_cnt
$_cnt ne 1
Truth table33%1/3
A and B
A= defined $_cntB= $_cnt ne 1
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | ▶ | _croak('Queue: (dequeue_timed count argument) is not valid') | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt) or int $_cnt != $_cnt
MC/DC0%0/3
not &looks_like_number($_cnt) or int $_cnt != $_cnt or $_cnt < 1
not &looks_like_number($_cnt)
int $_cnt != $_cnt
$_cnt < 1
Truth table0%0/4
not(A) or B or C
A= not &looks_like_number($_cnt)B= int $_cnt != $_cntC= $_cnt < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 971 | if (!looks_like_number($_cnt) || int($_cnt) != $_cnt || $_cnt < 1); | ||||||||||||||||||||||||||||||||||||||||||
| 972 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 973 | 4 | $_cnt = 1; | |||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||
| 976 | 4 | ▶ | if (! $_timeout || $_timeout < 0.0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $_timeout or $_timeout < 0
MC/DC0%0/2
not $_timeout or $_timeout < 0
not $_timeout
$_timeout < 0
Truth table33%1/3
not(A) or B
A= not $_timeoutB= $_timeout < 0
| |||||||||||||||||||||||||||||||||||||||||||
| 977 | 4 | _req_queue('O~QUN', $_id.$LF . $_cnt.$LF, my($_len), my($_buf)); | |||||||||||||||||||||||||||||||||||||||||
| 978 | 4 | ▶ | return if ($_len < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | ▶ | return ($_cnt == 1) ? $_thaw->($_buf)[0] : @{ $_thaw->($_buf) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||||||||||||||||
| 982 | 0 | _req_queue('O~QUD', $_id.$LF . $_cnt.$LF, my($_len), my($_buf)); | |||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | ▶ | return $_thaw->($_buf)[0] if ($_len > 0 && $_cnt == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$_len > 0 and $_cnt == 1
MC/DC0%0/2
$_len > 0 and $_cnt == 1
$_len > 0
$_cnt == 1
Truth table0%0/3
A and B
A= $_len > 0B= $_cnt == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 985 | 0 | ▶ | return @{ $_thaw->($_buf) } if ($_len > 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | return if ($_len == -2); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | 0 | $_Q->{_qr_mutex}->lock(); | |||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | $_timeout = $_timeout - (MCE::Util::_time() - $_start) - 0.045; | |||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | ▶ | $_timeout = 0.0 if $_timeout < 0.045; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||||||||||||||||
| 992 | 0 | CORE::vec(my $_r, CORE::fileno($_Q->{_qr_sock}), 1) = 1; | |||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | if (CORE::select($_r, undef, undef, $_timeout) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | MCE::Util::_sysread($_Q->{_qr_sock}, my($_next), 1); | |||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $_Q->{_qr_mutex}->unlock(); | |||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | _req_queue('O~QUN', $_id.$LF . $_cnt.$LF, my($_len), my($_buf)); | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | ▶ | return if ($_len < 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | return ($_cnt == 1) ? $_thaw->($_buf)[0] : @{ $_thaw->($_buf) }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | $_Q->{_qr_mutex}->unlock(); | |||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | _req1('O~QUT', $_id.$LF); | |||||||||||||||||||||||||||||||||||||||||
| 1003 | 0 | MCE::Util::_sleep(0.045); # yield | |||||||||||||||||||||||||||||||||||||||||
| 1004 | |||||||||||||||||||||||||||||||||||||||||||
| 1005 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | 4 | ▶ | sub pending { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 4 | ▶ | (@_ == 1 && !wantarray) ? _size('pending', @_) : _auto('pending', @_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and not wantarray
MC/DC0%0/2
@_ == 1 and not wantarray
@_ == 1
not wantarray
Truth table33%1/3
A and not(B)
A= @_ == 1B= not wantarray
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||
| 1012 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||
| 1014 | __END__ | ||||||||||||||||||||||||||||||||||||||||||