| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package IPC::Shm::Tied::ARRAY; |
|
2
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
|
6
|
|
|
|
|
108
|
|
|
|
6
|
|
|
|
|
215
|
|
|
3
|
6
|
|
|
6
|
|
33
|
use strict; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
209
|
|
|
4
|
6
|
|
|
6
|
|
31
|
use Carp; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
487
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (c) 2014 by Kevin Cody-Little |
|
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
|
|
|
6
|
|
32
|
use vars qw( @ISA ); |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
396
|
|
|
26
|
|
|
|
|
|
|
@ISA = qw( IPC::Shm::Tied ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
6
|
|
|
6
|
|
31
|
use IPC::Shm::Make; |
|
|
6
|
|
|
|
|
35
|
|
|
|
6
|
|
|
|
|
7508
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub EMPTY { |
|
32
|
2
|
|
|
2
|
1
|
9
|
return []; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub TIEARRAY { |
|
36
|
1
|
|
|
1
|
|
3
|
my ( $class, $this ) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
1
|
|
|
|
|
6
|
return bless $this, $class; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub FETCH { |
|
42
|
0
|
|
|
0
|
|
0
|
my ( $this, $index ) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
my $locked = $this->readlock; |
|
45
|
0
|
|
|
|
|
0
|
$this->fetch; |
|
46
|
0
|
0
|
|
|
|
0
|
$this->unlock if $locked; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
0
|
my $rv = $this->vcache->[$index]; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
0
|
return ref( $rv ) ? getback( $rv ) : $rv; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub STORE { |
|
54
|
0
|
|
|
0
|
|
0
|
my ( $this, $index, $value ) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
makeshm( \$value ); |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
my $locked = $this->writelock; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
$this->fetch; |
|
61
|
0
|
|
|
|
|
0
|
my $vcache = $this->vcache; |
|
62
|
0
|
|
|
|
|
0
|
my $oldval = $vcache->[$index]; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
0
|
$vcache->[$index] = $value; |
|
65
|
0
|
|
|
|
|
0
|
$this->flush; |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
0
|
$this->unlock if $locked; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
0
|
|
|
0
|
$this->standin_discard( $oldval ) if ( $oldval and ref( $oldval ) ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
return $value; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub FETCHSIZE { |
|
75
|
0
|
|
|
0
|
|
0
|
my ( $this ) = @_; |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
my $locked = $this->readlock; |
|
78
|
0
|
|
|
|
|
0
|
$this->fetch; |
|
79
|
0
|
0
|
|
|
|
0
|
$this->unlock if $locked; |
|
80
|
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
0
|
return scalar @{$this->vcache}; |
|
|
0
|
|
|
|
|
0
|
|
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub STORESIZE { |
|
85
|
0
|
|
|
0
|
|
0
|
my ( $this, $newcount ) = @_; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
0
|
my $oldcount = $this->FETCHSIZE; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
$this->writelock; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
0
|
if ( $newcount > $oldcount ) { |
|
|
|
0
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
0
|
for ( my $i = $oldcount; $i < $newcount; $i++ ) { |
|
93
|
0
|
|
|
|
|
0
|
$this->PUSH( undef ); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
elsif ( $newcount < $oldcount ) { |
|
98
|
0
|
|
|
|
|
0
|
for ( my $i = $oldcount; $i > $newcount; $i-- ) { |
|
99
|
0
|
|
|
|
|
0
|
$this->POP; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
$this->unlock; |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
return 1; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub EXTEND { |
|
109
|
0
|
|
|
0
|
|
0
|
my ( $this, $count ) = @_; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
0
|
$this->STORESIZE( $count ); |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
0
|
return 1; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub EXISTS { |
|
117
|
0
|
|
|
0
|
|
0
|
my ( $this, $index ) = @_; |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
0
|
my $locked = $this->readlock; |
|
120
|
0
|
|
|
|
|
0
|
$this->fetch; |
|
121
|
0
|
0
|
|
|
|
0
|
$this->unlock if $locked; |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
0
|
return exists $this->vcache->[$index]; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub DELETE { |
|
127
|
0
|
|
|
0
|
|
0
|
my ( $this, $index ) = @_; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
$this->STORE( $index, undef ); |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
0
|
return 1; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub CLEAR { |
|
135
|
1
|
|
|
1
|
|
2
|
my ( $this ) = @_; |
|
136
|
|
|
|
|
|
|
|
|
137
|
1
|
|
|
|
|
8
|
my $locked = $this->writelock; |
|
138
|
|
|
|
|
|
|
|
|
139
|
1
|
|
|
|
|
20
|
$this->fetch; |
|
140
|
1
|
|
|
|
|
5
|
my $vcache = $this->vcache; |
|
141
|
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
3
|
$this->vcache( $this->EMPTY ); |
|
143
|
1
|
|
|
|
|
4
|
$this->flush; |
|
144
|
|
|
|
|
|
|
|
|
145
|
1
|
50
|
|
|
|
182
|
$this->unlock if $locked; |
|
146
|
|
|
|
|
|
|
|
|
147
|
1
|
|
|
|
|
12
|
foreach my $oldval ( @{$vcache} ) { |
|
|
1
|
|
|
|
|
2
|
|
|
148
|
0
|
0
|
0
|
|
|
0
|
$this->standin_discard( $oldval ) if ( $oldval and ref( $oldval ) ); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
3
|
return 1; |
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub PUSH { |
|
155
|
0
|
|
|
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; |
|
|
0
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
} |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
$this->flush; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
return 1; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub POP { |
|
175
|
0
|
|
|
0
|
|
|
my ( $this ) = @_; |
|
176
|
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my $locked = $this->writelock; |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
$this->fetch; |
|
180
|
0
|
|
|
|
|
|
my $vcache = $this->vcache; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
0
|
|
|
|
|
unless ( scalar @{$vcache} ) { |
|
|
0
|
|
|
|
|
|
|
|
183
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
184
|
0
|
|
|
|
|
|
return; |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $rv = pop @{$vcache}; |
|
|
0
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
$this->flush; |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
191
|
|
|
|
|
|
|
|
|
192
|
0
|
0
|
|
|
|
|
return ref( $rv ) ? getback_discard( $rv ) : $rv; |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub SHIFT { |
|
196
|
0
|
|
|
0
|
|
|
my ( $this ) = @_; |
|
197
|
|
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
my $locked = $this->writelock; |
|
199
|
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
$this->fetch; |
|
201
|
0
|
|
|
|
|
|
my $vcache = $this->vcache; |
|
202
|
|
|
|
|
|
|
|
|
203
|
0
|
0
|
|
|
|
|
unless ( scalar @{$vcache} ) { |
|
|
0
|
|
|
|
|
|
|
|
204
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
205
|
0
|
|
|
|
|
|
return; |
|
206
|
|
|
|
|
|
|
} |
|
207
|
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
my $rv = shift @{$vcache}; |
|
|
0
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
$this->flush; |
|
210
|
|
|
|
|
|
|
|
|
211
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
0
|
|
|
|
|
return ref( $rv ) ? getback_discard( $rv ) : $rv; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub UNSHIFT { |
|
217
|
0
|
|
|
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; |
|
|
0
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
$this->flush; |
|
230
|
|
|
|
|
|
|
|
|
231
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
232
|
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
return 1; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub SPLICE { |
|
237
|
0
|
|
|
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 ); |
|
|
0
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
$this->flush; |
|
253
|
0
|
0
|
|
|
|
|
$this->unlock if $locked; |
|
254
|
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
my @retval = (); |
|
256
|
0
|
|
|
|
|
|
foreach my $oldval ( @oldval ) { |
|
257
|
0
|
0
|
|
|
|
|
push @retval, ref( $oldval ) |
|
258
|
|
|
|
|
|
|
? getback_discard( $oldval ) |
|
259
|
|
|
|
|
|
|
: $oldval; |
|
260
|
|
|
|
|
|
|
} |
|
261
|
|
|
|
|
|
|
|
|
262
|
0
|
0
|
|
|
|
|
return wantarray ? @retval : pop( @retval ); |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=head1 AUTHOR |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Kevin Cody-Little |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=cut |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
1; |