| 1 | package IPC::Shm::Tied::ARRAY; | ||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||
| 7 | # Copyright (c) 2014 by Kevin Cody-Little <kcody@cpan.org> | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # This code may be modified or redistributed under the terms | ||||||||||||||||||||||||||||
| 10 | # of either the Artistic or GNU General Public licenses, at | ||||||||||||||||||||||||||||
| 11 | # the modifier or redistributor's discretion. | ||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | IPC::Shm::Tied::ARRAY | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | This class is part of the IPC::Shm implementation. You should not be using it directly. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | # Loaded from IPC::Shm::Tied, so don't reload it | ||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use vars qw( @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 26 | 6 | @ISA = qw( IPC::Shm::Tied ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 6 | ▶ | use IPC::Shm::Make; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 2 | ▶ | sub EMPTY { | ||||||||||||||||||||||||||
|
Subroutine
EMPTY: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 32 | 2 | return []; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub TIEARRAY { | ||||||||||||||||||||||||||
|
Subroutine
TIEARRAY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | 1 | my ( $class, $this ) = @_; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 1 | return bless $this, $class; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub FETCH { | ||||||||||||||||||||||||||
|
Subroutine
FETCH: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 42 | 0 | my ( $this, $index ) = @_; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | my $locked = $this->readlock; | |||||||||||||||||||||||||||
| 45 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 46 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | my $rv = $this->vcache->[$index]; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return ref( $rv ) ? getback( $rv ) : $rv; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 54 | 0 | my ( $this, $index, $value ) = @_; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | makeshm( \$value ); | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 61 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 62 | 0 | my $oldval = $vcache->[$index]; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | $vcache->[$index] = $value; | |||||||||||||||||||||||||||
| 65 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | $this->standin_discard( $oldval ) if ( $oldval and ref( $oldval ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$oldval and ref $oldval
MC/DC0%0/2
$oldval and ref $oldval
$oldval
ref $oldval
Truth table0%0/3
A and B
A= $oldvalB= ref $oldval
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | return $value; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | sub FETCHSIZE { | ||||||||||||||||||||||||||
|
Subroutine
FETCHSIZE: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 75 | 0 | my ( $this ) = @_; | |||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | my $locked = $this->readlock; | |||||||||||||||||||||||||||
| 78 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 79 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | return scalar @{$this->vcache}; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub STORESIZE { | ||||||||||||||||||||||||||
|
Subroutine
STORESIZE: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 85 | 0 | my ( $this, $newcount ) = @_; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | my $oldcount = $this->FETCHSIZE; | |||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | $this->writelock; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( $newcount > $oldcount ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | for ( my $i = $oldcount; $i < $newcount; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 0 | $this->PUSH( undef ); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | elsif ( $newcount < $oldcount ) { | ||||||||||||||||||||||||||||
| 98 | 0 | ▶ | for ( my $i = $oldcount; $i > $newcount; $i-- ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | $this->POP; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 0 | $this->unlock; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | return 1; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub EXTEND { | ||||||||||||||||||||||||||
|
Subroutine
EXTEND: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 109 | 0 | my ( $this, $count ) = @_; | |||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 0 | $this->STORESIZE( $count ); | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | return 1; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub EXISTS { | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 117 | 0 | my ( $this, $index ) = @_; | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | my $locked = $this->readlock; | |||||||||||||||||||||||||||
| 120 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | return exists $this->vcache->[$index]; | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub DELETE { | ||||||||||||||||||||||||||
|
Subroutine
DELETE: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 127 | 0 | my ( $this, $index ) = @_; | |||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | $this->STORE( $index, undef ); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | return 1; | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 1 | ▶ | sub CLEAR { | ||||||||||||||||||||||||||
|
Subroutine
CLEAR: called CC=5 SCAR=18.7
| |||||||||||||||||||||||||||||
| 135 | 1 | my ( $this ) = @_; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 1 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1 | $this->fetch; | |||||||||||||||||||||||||||
| 140 | 1 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | $this->vcache( $this->EMPTY ); | |||||||||||||||||||||||||||
| 143 | 1 | $this->flush; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 1 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 1 | foreach my $oldval ( @{$vcache} ) { | |||||||||||||||||||||||||||
| 148 | 0 | ▶ | $this->standin_discard( $oldval ) if ( $oldval and ref( $oldval ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$oldval and ref $oldval
MC/DC0%0/2
$oldval and ref $oldval
$oldval
ref $oldval
Truth table0%0/3
A and B
A= $oldvalB= ref $oldval
| |||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 1 | return 1; | |||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub PUSH { | ||||||||||||||||||||||||||
|
Subroutine
PUSH: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 155 | 0 | my ( $this, @list ) = @_; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 160 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 0 | foreach my $newval ( @list ) { | |||||||||||||||||||||||||||
| 163 | 0 | makeshm( \$newval ); | |||||||||||||||||||||||||||
| 164 | 0 | push @{$vcache}, $newval; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | return 1; | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | ▶ | sub POP { | ||||||||||||||||||||||||||
|
Subroutine
POP: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 175 | 0 | my ( $this ) = @_; | |||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 180 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | unless ( scalar @{$vcache} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 184 | 0 | return; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | my $rv = pop @{$vcache}; | |||||||||||||||||||||||||||
| 188 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return ref( $rv ) ? getback_discard( $rv ) : $rv; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub SHIFT { | ||||||||||||||||||||||||||
|
Subroutine
SHIFT: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 196 | 0 | my ( $this ) = @_; | |||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 201 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | unless ( scalar @{$vcache} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | return; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | my $rv = shift @{$vcache}; | |||||||||||||||||||||||||||
| 209 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return ref( $rv ) ? getback_discard( $rv ) : $rv; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub UNSHIFT { | ||||||||||||||||||||||||||
|
Subroutine
UNSHIFT: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 217 | 0 | my ( $this, @list ) = @_; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 222 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | foreach my $newval ( @list ) { | |||||||||||||||||||||||||||
| 225 | 0 | makeshm( \$newval ); | |||||||||||||||||||||||||||
| 226 | 0 | unshift @{$vcache}, $newval; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 0 | return 1; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub SPLICE { | ||||||||||||||||||||||||||
|
Subroutine
SPLICE: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 237 | 0 | my ( $this, $offset, $length, @list ) = @_; | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | my $locked = $this->writelock; | |||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | $this->fetch; | |||||||||||||||||||||||||||
| 242 | 0 | my $vcache = $this->vcache; | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | my @newval = (); | |||||||||||||||||||||||||||
| 245 | 0 | foreach my $newval ( @list ) { | |||||||||||||||||||||||||||
| 246 | 0 | makeshm( \$newval ); | |||||||||||||||||||||||||||
| 247 | 0 | push @newval, $newval; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | my @oldval = splice( @{$vcache}, $offset, $length, @newval ); | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | $this->flush; | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | $this->unlock if $locked; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 0 | my @retval = (); | |||||||||||||||||||||||||||
| 256 | 0 | foreach my $oldval ( @oldval ) { | |||||||||||||||||||||||||||
| 257 | 0 | ▶ | push @retval, ref( $oldval ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | ? getback_discard( $oldval ) | ||||||||||||||||||||||||||||
| 259 | : $oldval; | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return wantarray ? @retval : pop( @retval ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | Kevin Cody-Little <kcody@cpan.org> | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 6 | 1; | |||||||||||||||||||||||||||