| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT |
|
2
|
|
|
|
|
|
|
#include "EXTERN.h" |
|
3
|
|
|
|
|
|
|
#include "perl.h" |
|
4
|
|
|
|
|
|
|
#include "XSUB.h" |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#include "ppport.h" |
|
7
|
|
|
|
|
|
|
#include "pool.h" |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#define EXTRACT_POOL(sv) \ |
|
10
|
|
|
|
|
|
|
if (!sv_isobject(sv) || !sv_derived_from(sv, "Data::Pool::Shared")) \ |
|
11
|
|
|
|
|
|
|
croak("Expected a Data::Pool::Shared object"); \ |
|
12
|
|
|
|
|
|
|
PoolHandle *h = INT2PTR(PoolHandle*, SvIV(SvRV(sv))); \ |
|
13
|
|
|
|
|
|
|
if (!h) croak("Attempted to use a destroyed Data::Pool::Shared object") |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
#define MAKE_OBJ(class, handle) \ |
|
16
|
|
|
|
|
|
|
SV *obj = newSViv(PTR2IV(handle)); \ |
|
17
|
|
|
|
|
|
|
SV *ref = newRV_noinc(obj); \ |
|
18
|
|
|
|
|
|
|
sv_bless(ref, gv_stashpv(class, GV_ADD)); \ |
|
19
|
|
|
|
|
|
|
RETVAL = ref |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#define CHECK_SLOT(h, slot) \ |
|
22
|
|
|
|
|
|
|
if ((UV)(slot) >= (h)->hdr->capacity) \ |
|
23
|
|
|
|
|
|
|
croak("slot %" UVuf " out of range (capacity %" UVuf ")", \ |
|
24
|
|
|
|
|
|
|
(UV)(slot), (UV)(h)->hdr->capacity) |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#define CHECK_ALLOCATED(h, slot) \ |
|
27
|
|
|
|
|
|
|
if (!pool_is_allocated(h, slot)) \ |
|
28
|
|
|
|
|
|
|
croak("slot %" UVuf " is not allocated", (UV)(slot)) |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
MODULE = Data::Pool::Shared PACKAGE = Data::Pool::Shared |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
SV * |
|
36
|
|
|
|
|
|
|
new(class, path, capacity, elem_size) |
|
37
|
|
|
|
|
|
|
const char *class |
|
38
|
|
|
|
|
|
|
SV *path |
|
39
|
|
|
|
|
|
|
UV capacity |
|
40
|
|
|
|
|
|
|
UV elem_size |
|
41
|
|
|
|
|
|
|
PREINIT: |
|
42
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
43
|
|
|
|
|
|
|
CODE: |
|
44
|
3
|
100
|
|
|
|
|
const char *p = SvOK(path) ? SvPV_nolen(path) : NULL; |
|
45
|
3
|
|
|
|
|
|
PoolHandle *h = pool_create(p, capacity, (uint32_t)elem_size, POOL_VAR_RAW, errbuf); |
|
46
|
3
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared->new: %s", errbuf); |
|
47
|
3
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
48
|
|
|
|
|
|
|
OUTPUT: |
|
49
|
|
|
|
|
|
|
RETVAL |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
SV * |
|
52
|
|
|
|
|
|
|
new_memfd(class, name, capacity, elem_size) |
|
53
|
|
|
|
|
|
|
const char *class |
|
54
|
|
|
|
|
|
|
const char *name |
|
55
|
|
|
|
|
|
|
UV capacity |
|
56
|
|
|
|
|
|
|
UV elem_size |
|
57
|
|
|
|
|
|
|
PREINIT: |
|
58
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
59
|
|
|
|
|
|
|
CODE: |
|
60
|
1
|
|
|
|
|
|
PoolHandle *h = pool_create_memfd(name, capacity, (uint32_t)elem_size, POOL_VAR_RAW, errbuf); |
|
61
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared->new_memfd: %s", errbuf); |
|
62
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
63
|
|
|
|
|
|
|
OUTPUT: |
|
64
|
|
|
|
|
|
|
RETVAL |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
SV * |
|
67
|
|
|
|
|
|
|
new_from_fd(class, fd) |
|
68
|
|
|
|
|
|
|
const char *class |
|
69
|
|
|
|
|
|
|
int fd |
|
70
|
|
|
|
|
|
|
PREINIT: |
|
71
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
72
|
|
|
|
|
|
|
CODE: |
|
73
|
1
|
|
|
|
|
|
PoolHandle *h = pool_open_fd(fd, POOL_VAR_RAW, errbuf); |
|
74
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared->new_from_fd: %s", errbuf); |
|
75
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
76
|
|
|
|
|
|
|
OUTPUT: |
|
77
|
|
|
|
|
|
|
RETVAL |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
void |
|
80
|
|
|
|
|
|
|
DESTROY(self) |
|
81
|
|
|
|
|
|
|
SV *self |
|
82
|
|
|
|
|
|
|
CODE: |
|
83
|
47
|
50
|
|
|
|
|
if (!SvROK(self)) return; |
|
84
|
47
|
|
|
|
|
|
PoolHandle *h = INT2PTR(PoolHandle*, SvIV(SvRV(self))); |
|
85
|
47
|
50
|
|
|
|
|
if (!h) return; |
|
86
|
47
|
|
|
|
|
|
sv_setiv(SvRV(self), 0); |
|
87
|
47
|
|
|
|
|
|
pool_destroy(h); |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
SV * |
|
90
|
|
|
|
|
|
|
alloc(self, ...) |
|
91
|
|
|
|
|
|
|
SV *self |
|
92
|
|
|
|
|
|
|
PREINIT: |
|
93
|
904
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
94
|
904
|
|
|
|
|
|
double timeout = -1; |
|
95
|
|
|
|
|
|
|
CODE: |
|
96
|
904
|
100
|
|
|
|
|
if (items > 1) timeout = SvNV(ST(1)); |
|
97
|
904
|
|
|
|
|
|
int64_t slot = pool_alloc(h, timeout); |
|
98
|
904
|
100
|
|
|
|
|
RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef; |
|
99
|
|
|
|
|
|
|
OUTPUT: |
|
100
|
|
|
|
|
|
|
RETVAL |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
SV * |
|
103
|
|
|
|
|
|
|
try_alloc(self) |
|
104
|
|
|
|
|
|
|
SV *self |
|
105
|
|
|
|
|
|
|
PREINIT: |
|
106
|
17
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
CODE: |
|
108
|
17
|
|
|
|
|
|
int64_t slot = pool_try_alloc(h); |
|
109
|
17
|
100
|
|
|
|
|
RETVAL = (slot >= 0) ? newSViv((IV)slot) : &PL_sv_undef; |
|
110
|
|
|
|
|
|
|
OUTPUT: |
|
111
|
|
|
|
|
|
|
RETVAL |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
bool |
|
114
|
|
|
|
|
|
|
free(self, slot) |
|
115
|
|
|
|
|
|
|
SV *self |
|
116
|
|
|
|
|
|
|
UV slot |
|
117
|
|
|
|
|
|
|
PREINIT: |
|
118
|
692
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
CODE: |
|
120
|
692
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
121
|
691
|
100
|
|
|
|
|
RETVAL = pool_free_slot(h, slot); |
|
122
|
|
|
|
|
|
|
OUTPUT: |
|
123
|
|
|
|
|
|
|
RETVAL |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
SV * |
|
126
|
|
|
|
|
|
|
get(self, slot) |
|
127
|
|
|
|
|
|
|
SV *self |
|
128
|
|
|
|
|
|
|
UV slot |
|
129
|
|
|
|
|
|
|
PREINIT: |
|
130
|
4
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
CODE: |
|
132
|
4
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
133
|
3
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
134
|
2
|
|
|
|
|
|
RETVAL = newSVpvn((const char *)pool_slot_ptr(h, slot), h->hdr->elem_size); |
|
135
|
|
|
|
|
|
|
OUTPUT: |
|
136
|
|
|
|
|
|
|
RETVAL |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
void |
|
139
|
|
|
|
|
|
|
set(self, slot, data) |
|
140
|
|
|
|
|
|
|
SV *self |
|
141
|
|
|
|
|
|
|
UV slot |
|
142
|
|
|
|
|
|
|
SV *data |
|
143
|
|
|
|
|
|
|
PREINIT: |
|
144
|
5
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
CODE: |
|
146
|
5
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
147
|
4
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
148
|
|
|
|
|
|
|
STRLEN len; |
|
149
|
4
|
|
|
|
|
|
const char *bytes = SvPV(data, len); |
|
150
|
4
|
50
|
|
|
|
|
if (len > h->hdr->elem_size) |
|
151
|
0
|
|
|
|
|
|
len = h->hdr->elem_size; |
|
152
|
4
|
|
|
|
|
|
memcpy(pool_slot_ptr(h, slot), bytes, len); |
|
153
|
4
|
100
|
|
|
|
|
if (len < h->hdr->elem_size) |
|
154
|
1
|
|
|
|
|
|
memset(pool_slot_ptr(h, slot) + len, 0, h->hdr->elem_size - len); |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
bool |
|
157
|
|
|
|
|
|
|
is_allocated(self, slot) |
|
158
|
|
|
|
|
|
|
SV *self |
|
159
|
|
|
|
|
|
|
UV slot |
|
160
|
|
|
|
|
|
|
PREINIT: |
|
161
|
6
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
CODE: |
|
163
|
6
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
164
|
5
|
100
|
|
|
|
|
RETVAL = pool_is_allocated(h, slot); |
|
165
|
|
|
|
|
|
|
OUTPUT: |
|
166
|
|
|
|
|
|
|
RETVAL |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
UV |
|
169
|
|
|
|
|
|
|
capacity(self) |
|
170
|
|
|
|
|
|
|
SV *self |
|
171
|
|
|
|
|
|
|
PREINIT: |
|
172
|
11
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
CODE: |
|
174
|
11
|
100
|
|
|
|
|
RETVAL = (UV)h->hdr->capacity; |
|
175
|
|
|
|
|
|
|
OUTPUT: |
|
176
|
|
|
|
|
|
|
RETVAL |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
UV |
|
179
|
|
|
|
|
|
|
elem_size(self) |
|
180
|
|
|
|
|
|
|
SV *self |
|
181
|
|
|
|
|
|
|
PREINIT: |
|
182
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
CODE: |
|
184
|
3
|
50
|
|
|
|
|
RETVAL = h->hdr->elem_size; |
|
185
|
|
|
|
|
|
|
OUTPUT: |
|
186
|
|
|
|
|
|
|
RETVAL |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
UV |
|
189
|
|
|
|
|
|
|
used(self) |
|
190
|
|
|
|
|
|
|
SV *self |
|
191
|
|
|
|
|
|
|
PREINIT: |
|
192
|
36
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
CODE: |
|
194
|
36
|
100
|
|
|
|
|
RETVAL = __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED); |
|
195
|
|
|
|
|
|
|
OUTPUT: |
|
196
|
|
|
|
|
|
|
RETVAL |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
UV |
|
199
|
|
|
|
|
|
|
available(self) |
|
200
|
|
|
|
|
|
|
SV *self |
|
201
|
|
|
|
|
|
|
PREINIT: |
|
202
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
CODE: |
|
204
|
2
|
50
|
|
|
|
|
RETVAL = (UV)h->hdr->capacity - __atomic_load_n(&h->hdr->used, __ATOMIC_RELAXED); |
|
205
|
|
|
|
|
|
|
OUTPUT: |
|
206
|
|
|
|
|
|
|
RETVAL |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
UV |
|
209
|
|
|
|
|
|
|
owner(self, slot) |
|
210
|
|
|
|
|
|
|
SV *self |
|
211
|
|
|
|
|
|
|
UV slot |
|
212
|
|
|
|
|
|
|
PREINIT: |
|
213
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
CODE: |
|
215
|
2
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
216
|
1
|
50
|
|
|
|
|
RETVAL = __atomic_load_n(&h->owners[slot], __ATOMIC_RELAXED); |
|
217
|
|
|
|
|
|
|
OUTPUT: |
|
218
|
|
|
|
|
|
|
RETVAL |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
UV |
|
221
|
|
|
|
|
|
|
recover_stale(self) |
|
222
|
|
|
|
|
|
|
SV *self |
|
223
|
|
|
|
|
|
|
PREINIT: |
|
224
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
CODE: |
|
226
|
2
|
50
|
|
|
|
|
RETVAL = pool_recover_stale(h); |
|
227
|
|
|
|
|
|
|
OUTPUT: |
|
228
|
|
|
|
|
|
|
RETVAL |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
void |
|
231
|
|
|
|
|
|
|
reset(self) |
|
232
|
|
|
|
|
|
|
SV *self |
|
233
|
|
|
|
|
|
|
PREINIT: |
|
234
|
10
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
CODE: |
|
236
|
10
|
|
|
|
|
|
pool_reset(h); |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
SV * |
|
239
|
|
|
|
|
|
|
path(self) |
|
240
|
|
|
|
|
|
|
SV *self |
|
241
|
|
|
|
|
|
|
PREINIT: |
|
242
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
CODE: |
|
244
|
3
|
100
|
|
|
|
|
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; |
|
245
|
|
|
|
|
|
|
OUTPUT: |
|
246
|
|
|
|
|
|
|
RETVAL |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
IV |
|
249
|
|
|
|
|
|
|
memfd(self) |
|
250
|
|
|
|
|
|
|
SV *self |
|
251
|
|
|
|
|
|
|
PREINIT: |
|
252
|
5
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
CODE: |
|
254
|
5
|
50
|
|
|
|
|
RETVAL = h->backing_fd; |
|
255
|
|
|
|
|
|
|
OUTPUT: |
|
256
|
|
|
|
|
|
|
RETVAL |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
IV |
|
259
|
|
|
|
|
|
|
eventfd(self) |
|
260
|
|
|
|
|
|
|
SV *self |
|
261
|
|
|
|
|
|
|
PREINIT: |
|
262
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
CODE: |
|
264
|
2
|
50
|
|
|
|
|
RETVAL = pool_create_eventfd(h); |
|
265
|
|
|
|
|
|
|
OUTPUT: |
|
266
|
|
|
|
|
|
|
RETVAL |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
void |
|
269
|
|
|
|
|
|
|
eventfd_set(self, fd) |
|
270
|
|
|
|
|
|
|
SV *self |
|
271
|
|
|
|
|
|
|
int fd |
|
272
|
|
|
|
|
|
|
PREINIT: |
|
273
|
0
|
0
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
CODE: |
|
275
|
0
|
0
|
|
|
|
|
if (h->notify_fd >= 0 && h->notify_fd != fd) close(h->notify_fd); |
|
|
|
0
|
|
|
|
|
|
|
276
|
0
|
|
|
|
|
|
h->notify_fd = fd; |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
IV |
|
279
|
|
|
|
|
|
|
fileno(self) |
|
280
|
|
|
|
|
|
|
SV *self |
|
281
|
|
|
|
|
|
|
PREINIT: |
|
282
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
CODE: |
|
284
|
3
|
50
|
|
|
|
|
RETVAL = h->notify_fd; |
|
285
|
|
|
|
|
|
|
OUTPUT: |
|
286
|
|
|
|
|
|
|
RETVAL |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
bool |
|
289
|
|
|
|
|
|
|
notify(self) |
|
290
|
|
|
|
|
|
|
SV *self |
|
291
|
|
|
|
|
|
|
PREINIT: |
|
292
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
CODE: |
|
294
|
3
|
50
|
|
|
|
|
RETVAL = pool_notify(h); |
|
295
|
|
|
|
|
|
|
OUTPUT: |
|
296
|
|
|
|
|
|
|
RETVAL |
|
297
|
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
SV * |
|
299
|
|
|
|
|
|
|
eventfd_consume(self) |
|
300
|
|
|
|
|
|
|
SV *self |
|
301
|
|
|
|
|
|
|
PREINIT: |
|
302
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
CODE: |
|
304
|
3
|
|
|
|
|
|
int64_t v = pool_eventfd_consume(h); |
|
305
|
3
|
100
|
|
|
|
|
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; |
|
306
|
|
|
|
|
|
|
OUTPUT: |
|
307
|
|
|
|
|
|
|
RETVAL |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
void |
|
310
|
|
|
|
|
|
|
sync(self) |
|
311
|
|
|
|
|
|
|
SV *self |
|
312
|
|
|
|
|
|
|
PREINIT: |
|
313
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
CODE: |
|
315
|
1
|
|
|
|
|
|
pool_msync(h); |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
void |
|
318
|
|
|
|
|
|
|
unlink(self_or_class, ...) |
|
319
|
|
|
|
|
|
|
SV *self_or_class |
|
320
|
|
|
|
|
|
|
CODE: |
|
321
|
|
|
|
|
|
|
const char *p; |
|
322
|
3
|
100
|
|
|
|
|
if (sv_isobject(self_or_class)) { |
|
323
|
2
|
|
|
|
|
|
PoolHandle *h = INT2PTR(PoolHandle*, SvIV(SvRV(self_or_class))); |
|
324
|
2
|
50
|
|
|
|
|
if (!h) croak("Attempted to use a destroyed object"); |
|
325
|
2
|
|
|
|
|
|
p = h->path; |
|
326
|
|
|
|
|
|
|
} else { |
|
327
|
1
|
50
|
|
|
|
|
if (items < 2) croak("Usage: ...->unlink($path)"); |
|
328
|
1
|
|
|
|
|
|
p = SvPV_nolen(ST(1)); |
|
329
|
|
|
|
|
|
|
} |
|
330
|
3
|
100
|
|
|
|
|
if (!p) croak("cannot unlink anonymous or memfd object"); |
|
331
|
2
|
50
|
|
|
|
|
if (unlink(p) != 0) |
|
332
|
0
|
|
|
|
|
|
croak("unlink(%s): %s", p, strerror(errno)); |
|
333
|
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
SV * |
|
335
|
|
|
|
|
|
|
stats(self) |
|
336
|
|
|
|
|
|
|
SV *self |
|
337
|
|
|
|
|
|
|
PREINIT: |
|
338
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
CODE: |
|
340
|
1
|
|
|
|
|
|
HV *hv = newHV(); |
|
341
|
1
|
|
|
|
|
|
PoolHeader *hdr = h->hdr; |
|
342
|
1
|
|
|
|
|
|
hv_store(hv, "capacity", 8, newSVuv((UV)hdr->capacity), 0); |
|
343
|
1
|
|
|
|
|
|
hv_store(hv, "elem_size", 9, newSVuv(hdr->elem_size), 0); |
|
344
|
1
|
|
|
|
|
|
hv_store(hv, "used", 4, newSVuv(__atomic_load_n(&hdr->used, __ATOMIC_RELAXED)), 0); |
|
345
|
1
|
|
|
|
|
|
hv_store(hv, "available", 9, |
|
346
|
|
|
|
|
|
|
newSVuv((UV)hdr->capacity - __atomic_load_n(&hdr->used, __ATOMIC_RELAXED)), 0); |
|
347
|
1
|
|
|
|
|
|
hv_store(hv, "waiters", 7, newSVuv(hdr->waiters), 0); |
|
348
|
1
|
|
|
|
|
|
hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0); |
|
349
|
1
|
|
|
|
|
|
hv_store(hv, "allocs", 6, newSVuv((UV)hdr->stat_allocs), 0); |
|
350
|
1
|
|
|
|
|
|
hv_store(hv, "frees", 5, newSVuv((UV)hdr->stat_frees), 0); |
|
351
|
1
|
|
|
|
|
|
hv_store(hv, "waits", 5, newSVuv((UV)hdr->stat_waits), 0); |
|
352
|
1
|
|
|
|
|
|
hv_store(hv, "timeouts", 8, newSVuv((UV)hdr->stat_timeouts), 0); |
|
353
|
1
|
|
|
|
|
|
hv_store(hv, "recoveries", 10, newSVuv(hdr->stat_recoveries), 0); |
|
354
|
1
|
|
|
|
|
|
RETVAL = newRV_noinc((SV *)hv); |
|
355
|
|
|
|
|
|
|
OUTPUT: |
|
356
|
|
|
|
|
|
|
RETVAL |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
SV * |
|
360
|
|
|
|
|
|
|
alloc_n(self, count, ...) |
|
361
|
|
|
|
|
|
|
SV *self |
|
362
|
|
|
|
|
|
|
UV count |
|
363
|
|
|
|
|
|
|
PREINIT: |
|
364
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
365
|
3
|
|
|
|
|
|
double timeout = -1; |
|
366
|
|
|
|
|
|
|
CODE: |
|
367
|
3
|
100
|
|
|
|
|
if (items > 2) timeout = SvNV(ST(2)); |
|
368
|
3
|
100
|
|
|
|
|
if (count == 0) { |
|
369
|
1
|
|
|
|
|
|
RETVAL = newRV_noinc((SV *)newAV()); |
|
370
|
|
|
|
|
|
|
} else { |
|
371
|
|
|
|
|
|
|
uint64_t *buf; |
|
372
|
2
|
50
|
|
|
|
|
Newx(buf, count, uint64_t); |
|
373
|
2
|
100
|
|
|
|
|
if (pool_alloc_n(h, buf, (uint32_t)count, timeout)) { |
|
374
|
1
|
|
|
|
|
|
AV *av = newAV(); |
|
375
|
1
|
|
|
|
|
|
av_extend(av, count - 1); |
|
376
|
4
|
100
|
|
|
|
|
for (UV i = 0; i < count; i++) |
|
377
|
3
|
|
|
|
|
|
av_push(av, newSViv((IV)buf[i])); |
|
378
|
1
|
|
|
|
|
|
RETVAL = newRV_noinc((SV *)av); |
|
379
|
|
|
|
|
|
|
} else { |
|
380
|
1
|
|
|
|
|
|
RETVAL = &PL_sv_undef; |
|
381
|
|
|
|
|
|
|
} |
|
382
|
2
|
|
|
|
|
|
Safefree(buf); |
|
383
|
|
|
|
|
|
|
} |
|
384
|
|
|
|
|
|
|
OUTPUT: |
|
385
|
|
|
|
|
|
|
RETVAL |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
UV |
|
388
|
|
|
|
|
|
|
free_n(self, slots_av) |
|
389
|
|
|
|
|
|
|
SV *self |
|
390
|
|
|
|
|
|
|
SV *slots_av |
|
391
|
|
|
|
|
|
|
PREINIT: |
|
392
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
393
|
|
|
|
|
|
|
CODE: |
|
394
|
3
|
100
|
|
|
|
|
if (!SvROK(slots_av) || SvTYPE(SvRV(slots_av)) != SVt_PVAV) |
|
|
|
50
|
|
|
|
|
|
|
395
|
1
|
|
|
|
|
|
croak("free_n: expected arrayref"); |
|
396
|
2
|
|
|
|
|
|
AV *av = (AV *)SvRV(slots_av); |
|
397
|
2
|
50
|
|
|
|
|
SSize_t len = av_top_index(av) + 1; |
|
398
|
2
|
100
|
|
|
|
|
if (len <= 0) { |
|
399
|
1
|
|
|
|
|
|
RETVAL = 0; |
|
400
|
|
|
|
|
|
|
} else { |
|
401
|
|
|
|
|
|
|
uint64_t *buf; |
|
402
|
1
|
50
|
|
|
|
|
Newx(buf, len, uint64_t); |
|
403
|
4
|
100
|
|
|
|
|
for (SSize_t i = 0; i < len; i++) { |
|
404
|
3
|
|
|
|
|
|
SV **svp = av_fetch(av, i, 0); |
|
405
|
3
|
50
|
|
|
|
|
buf[i] = svp ? (uint64_t)SvUV(*svp) : 0; |
|
406
|
|
|
|
|
|
|
} |
|
407
|
1
|
|
|
|
|
|
RETVAL = pool_free_n(h, buf, (uint32_t)len); |
|
408
|
1
|
|
|
|
|
|
Safefree(buf); |
|
409
|
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
OUTPUT: |
|
411
|
|
|
|
|
|
|
RETVAL |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
SV * |
|
414
|
|
|
|
|
|
|
allocated_slots(self) |
|
415
|
|
|
|
|
|
|
SV *self |
|
416
|
|
|
|
|
|
|
PREINIT: |
|
417
|
6
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
CODE: |
|
419
|
6
|
|
|
|
|
|
AV *av = newAV(); |
|
420
|
6
|
|
|
|
|
|
uint64_t cap = h->hdr->capacity; |
|
421
|
6
|
|
|
|
|
|
uint32_t nwords = h->bitmap_words; |
|
422
|
13
|
100
|
|
|
|
|
for (uint32_t widx = 0; widx < nwords; widx++) { |
|
423
|
7
|
|
|
|
|
|
uint64_t word = __atomic_load_n(&h->bitmap[widx], __ATOMIC_RELAXED); |
|
424
|
36
|
100
|
|
|
|
|
while (word) { |
|
425
|
29
|
|
|
|
|
|
int bit = __builtin_ctzll(word); |
|
426
|
29
|
|
|
|
|
|
uint64_t slot = (uint64_t)widx * 64 + bit; |
|
427
|
29
|
50
|
|
|
|
|
if (slot < cap) |
|
428
|
29
|
|
|
|
|
|
av_push(av, newSViv((IV)slot)); |
|
429
|
29
|
|
|
|
|
|
word &= word - 1; |
|
430
|
|
|
|
|
|
|
} |
|
431
|
|
|
|
|
|
|
} |
|
432
|
6
|
|
|
|
|
|
RETVAL = newRV_noinc((SV *)av); |
|
433
|
|
|
|
|
|
|
OUTPUT: |
|
434
|
|
|
|
|
|
|
RETVAL |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
UV |
|
437
|
|
|
|
|
|
|
ptr(self, slot) |
|
438
|
|
|
|
|
|
|
SV *self |
|
439
|
|
|
|
|
|
|
UV slot |
|
440
|
|
|
|
|
|
|
PREINIT: |
|
441
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
CODE: |
|
443
|
3
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
444
|
2
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
445
|
1
|
50
|
|
|
|
|
RETVAL = PTR2UV(pool_slot_ptr(h, slot)); |
|
446
|
|
|
|
|
|
|
OUTPUT: |
|
447
|
|
|
|
|
|
|
RETVAL |
|
448
|
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
UV |
|
450
|
|
|
|
|
|
|
data_ptr(self) |
|
451
|
|
|
|
|
|
|
SV *self |
|
452
|
|
|
|
|
|
|
PREINIT: |
|
453
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
CODE: |
|
455
|
1
|
50
|
|
|
|
|
RETVAL = PTR2UV(h->data); |
|
456
|
|
|
|
|
|
|
OUTPUT: |
|
457
|
|
|
|
|
|
|
RETVAL |
|
458
|
|
|
|
|
|
|
|
|
459
|
|
|
|
|
|
|
SV * |
|
460
|
|
|
|
|
|
|
slot_sv(self, slot) |
|
461
|
|
|
|
|
|
|
SV *self |
|
462
|
|
|
|
|
|
|
UV slot |
|
463
|
|
|
|
|
|
|
PREINIT: |
|
464
|
4
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
CODE: |
|
466
|
4
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
467
|
4
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
468
|
3
|
|
|
|
|
|
RETVAL = newSV(0); |
|
469
|
3
|
|
|
|
|
|
sv_upgrade(RETVAL, SVt_PV); |
|
470
|
3
|
|
|
|
|
|
SvPV_set(RETVAL, (char *)pool_slot_ptr(h, slot)); |
|
471
|
3
|
|
|
|
|
|
SvLEN_set(RETVAL, 0); |
|
472
|
3
|
|
|
|
|
|
SvCUR_set(RETVAL, h->hdr->elem_size); |
|
473
|
3
|
|
|
|
|
|
SvPOK_on(RETVAL); |
|
474
|
3
|
|
|
|
|
|
SvREADONLY_on(RETVAL); |
|
475
|
|
|
|
|
|
|
OUTPUT: |
|
476
|
|
|
|
|
|
|
RETVAL |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
MODULE = Data::Pool::Shared PACKAGE = Data::Pool::Shared::I64 |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
SV * |
|
484
|
|
|
|
|
|
|
new(class, path, capacity) |
|
485
|
|
|
|
|
|
|
const char *class |
|
486
|
|
|
|
|
|
|
SV *path |
|
487
|
|
|
|
|
|
|
UV capacity |
|
488
|
|
|
|
|
|
|
PREINIT: |
|
489
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
490
|
|
|
|
|
|
|
CODE: |
|
491
|
24
|
100
|
|
|
|
|
const char *p = SvOK(path) ? SvPV_nolen(path) : NULL; |
|
492
|
24
|
|
|
|
|
|
PoolHandle *h = pool_create(p, capacity, sizeof(int64_t), POOL_VAR_I64, errbuf); |
|
493
|
24
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I64->new: %s", errbuf); |
|
494
|
24
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
495
|
|
|
|
|
|
|
OUTPUT: |
|
496
|
|
|
|
|
|
|
RETVAL |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
SV * |
|
499
|
|
|
|
|
|
|
new_memfd(class, name, capacity) |
|
500
|
|
|
|
|
|
|
const char *class |
|
501
|
|
|
|
|
|
|
const char *name |
|
502
|
|
|
|
|
|
|
UV capacity |
|
503
|
|
|
|
|
|
|
PREINIT: |
|
504
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
505
|
|
|
|
|
|
|
CODE: |
|
506
|
2
|
|
|
|
|
|
PoolHandle *h = pool_create_memfd(name, capacity, sizeof(int64_t), POOL_VAR_I64, errbuf); |
|
507
|
2
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I64->new_memfd: %s", errbuf); |
|
508
|
2
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
509
|
|
|
|
|
|
|
OUTPUT: |
|
510
|
|
|
|
|
|
|
RETVAL |
|
511
|
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
SV * |
|
513
|
|
|
|
|
|
|
new_from_fd(class, fd) |
|
514
|
|
|
|
|
|
|
const char *class |
|
515
|
|
|
|
|
|
|
int fd |
|
516
|
|
|
|
|
|
|
PREINIT: |
|
517
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
518
|
|
|
|
|
|
|
CODE: |
|
519
|
1
|
|
|
|
|
|
PoolHandle *h = pool_open_fd(fd, POOL_VAR_I64, errbuf); |
|
520
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I64->new_from_fd: %s", errbuf); |
|
521
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
522
|
|
|
|
|
|
|
OUTPUT: |
|
523
|
|
|
|
|
|
|
RETVAL |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
IV |
|
526
|
|
|
|
|
|
|
get(self, slot) |
|
527
|
|
|
|
|
|
|
SV *self |
|
528
|
|
|
|
|
|
|
UV slot |
|
529
|
|
|
|
|
|
|
PREINIT: |
|
530
|
64
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
CODE: |
|
532
|
64
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
533
|
63
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
534
|
62
|
|
|
|
|
|
RETVAL = (IV)pool_get_i64(h, slot); |
|
535
|
|
|
|
|
|
|
OUTPUT: |
|
536
|
|
|
|
|
|
|
RETVAL |
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
void |
|
539
|
|
|
|
|
|
|
set(self, slot, val) |
|
540
|
|
|
|
|
|
|
SV *self |
|
541
|
|
|
|
|
|
|
UV slot |
|
542
|
|
|
|
|
|
|
IV val |
|
543
|
|
|
|
|
|
|
PREINIT: |
|
544
|
615
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
CODE: |
|
546
|
615
|
100
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
547
|
614
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
548
|
613
|
|
|
|
|
|
pool_set_i64(h, slot, (int64_t)val); |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
bool |
|
551
|
|
|
|
|
|
|
cas(self, slot, expected, desired) |
|
552
|
|
|
|
|
|
|
SV *self |
|
553
|
|
|
|
|
|
|
UV slot |
|
554
|
|
|
|
|
|
|
IV expected |
|
555
|
|
|
|
|
|
|
IV desired |
|
556
|
|
|
|
|
|
|
PREINIT: |
|
557
|
4
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
CODE: |
|
559
|
4
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
560
|
4
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
561
|
3
|
100
|
|
|
|
|
RETVAL = pool_cas_i64(h, slot, (int64_t)expected, (int64_t)desired); |
|
562
|
|
|
|
|
|
|
OUTPUT: |
|
563
|
|
|
|
|
|
|
RETVAL |
|
564
|
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
IV |
|
566
|
|
|
|
|
|
|
cmpxchg(self, slot, expected, desired) |
|
567
|
|
|
|
|
|
|
SV *self |
|
568
|
|
|
|
|
|
|
UV slot |
|
569
|
|
|
|
|
|
|
IV expected |
|
570
|
|
|
|
|
|
|
IV desired |
|
571
|
|
|
|
|
|
|
PREINIT: |
|
572
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
573
|
|
|
|
|
|
|
CODE: |
|
574
|
2
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
575
|
2
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
576
|
2
|
|
|
|
|
|
RETVAL = (IV)pool_cmpxchg_i64(h, slot, (int64_t)expected, (int64_t)desired); |
|
577
|
|
|
|
|
|
|
OUTPUT: |
|
578
|
|
|
|
|
|
|
RETVAL |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
IV |
|
581
|
|
|
|
|
|
|
xchg(self, slot, val) |
|
582
|
|
|
|
|
|
|
SV *self |
|
583
|
|
|
|
|
|
|
UV slot |
|
584
|
|
|
|
|
|
|
IV val |
|
585
|
|
|
|
|
|
|
PREINIT: |
|
586
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
CODE: |
|
588
|
1
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
589
|
1
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
590
|
1
|
|
|
|
|
|
RETVAL = (IV)pool_xchg_i64(h, slot, (int64_t)val); |
|
591
|
|
|
|
|
|
|
OUTPUT: |
|
592
|
|
|
|
|
|
|
RETVAL |
|
593
|
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
IV |
|
595
|
|
|
|
|
|
|
add(self, slot, delta) |
|
596
|
|
|
|
|
|
|
SV *self |
|
597
|
|
|
|
|
|
|
UV slot |
|
598
|
|
|
|
|
|
|
IV delta |
|
599
|
|
|
|
|
|
|
PREINIT: |
|
600
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
CODE: |
|
602
|
3
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
603
|
3
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
604
|
2
|
|
|
|
|
|
RETVAL = (IV)pool_add_i64(h, slot, (int64_t)delta); |
|
605
|
|
|
|
|
|
|
OUTPUT: |
|
606
|
|
|
|
|
|
|
RETVAL |
|
607
|
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
IV |
|
609
|
|
|
|
|
|
|
incr(self, slot) |
|
610
|
|
|
|
|
|
|
SV *self |
|
611
|
|
|
|
|
|
|
UV slot |
|
612
|
|
|
|
|
|
|
PREINIT: |
|
613
|
4
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
614
|
|
|
|
|
|
|
CODE: |
|
615
|
4
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
616
|
4
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
617
|
3
|
|
|
|
|
|
RETVAL = (IV)pool_add_i64(h, slot, 1); |
|
618
|
|
|
|
|
|
|
OUTPUT: |
|
619
|
|
|
|
|
|
|
RETVAL |
|
620
|
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
IV |
|
622
|
|
|
|
|
|
|
decr(self, slot) |
|
623
|
|
|
|
|
|
|
SV *self |
|
624
|
|
|
|
|
|
|
UV slot |
|
625
|
|
|
|
|
|
|
PREINIT: |
|
626
|
3
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
CODE: |
|
628
|
3
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
629
|
3
|
100
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
630
|
2
|
|
|
|
|
|
RETVAL = (IV)pool_add_i64(h, slot, -1); |
|
631
|
|
|
|
|
|
|
OUTPUT: |
|
632
|
|
|
|
|
|
|
RETVAL |
|
633
|
|
|
|
|
|
|
|
|
634
|
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
MODULE = Data::Pool::Shared PACKAGE = Data::Pool::Shared::F64 |
|
636
|
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
SV * |
|
640
|
|
|
|
|
|
|
new(class, path, capacity) |
|
641
|
|
|
|
|
|
|
const char *class |
|
642
|
|
|
|
|
|
|
SV *path |
|
643
|
|
|
|
|
|
|
UV capacity |
|
644
|
|
|
|
|
|
|
PREINIT: |
|
645
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
646
|
|
|
|
|
|
|
CODE: |
|
647
|
2
|
50
|
|
|
|
|
const char *p = SvOK(path) ? SvPV_nolen(path) : NULL; |
|
648
|
2
|
|
|
|
|
|
PoolHandle *h = pool_create(p, capacity, sizeof(double), POOL_VAR_F64, errbuf); |
|
649
|
2
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::F64->new: %s", errbuf); |
|
650
|
2
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
651
|
|
|
|
|
|
|
OUTPUT: |
|
652
|
|
|
|
|
|
|
RETVAL |
|
653
|
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
SV * |
|
655
|
|
|
|
|
|
|
new_memfd(class, name, capacity) |
|
656
|
|
|
|
|
|
|
const char *class |
|
657
|
|
|
|
|
|
|
const char *name |
|
658
|
|
|
|
|
|
|
UV capacity |
|
659
|
|
|
|
|
|
|
PREINIT: |
|
660
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
661
|
|
|
|
|
|
|
CODE: |
|
662
|
1
|
|
|
|
|
|
PoolHandle *h = pool_create_memfd(name, capacity, sizeof(double), POOL_VAR_F64, errbuf); |
|
663
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::F64->new_memfd: %s", errbuf); |
|
664
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
665
|
|
|
|
|
|
|
OUTPUT: |
|
666
|
|
|
|
|
|
|
RETVAL |
|
667
|
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
SV * |
|
669
|
|
|
|
|
|
|
new_from_fd(class, fd) |
|
670
|
|
|
|
|
|
|
const char *class |
|
671
|
|
|
|
|
|
|
int fd |
|
672
|
|
|
|
|
|
|
PREINIT: |
|
673
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
674
|
|
|
|
|
|
|
CODE: |
|
675
|
1
|
|
|
|
|
|
PoolHandle *h = pool_open_fd(fd, POOL_VAR_F64, errbuf); |
|
676
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::F64->new_from_fd: %s", errbuf); |
|
677
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
678
|
|
|
|
|
|
|
OUTPUT: |
|
679
|
|
|
|
|
|
|
RETVAL |
|
680
|
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
NV |
|
682
|
|
|
|
|
|
|
get(self, slot) |
|
683
|
|
|
|
|
|
|
SV *self |
|
684
|
|
|
|
|
|
|
UV slot |
|
685
|
|
|
|
|
|
|
PREINIT: |
|
686
|
7
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
CODE: |
|
688
|
7
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
689
|
7
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
690
|
7
|
|
|
|
|
|
RETVAL = pool_get_f64(h, slot); |
|
691
|
|
|
|
|
|
|
OUTPUT: |
|
692
|
|
|
|
|
|
|
RETVAL |
|
693
|
|
|
|
|
|
|
|
|
694
|
|
|
|
|
|
|
void |
|
695
|
|
|
|
|
|
|
set(self, slot, val) |
|
696
|
|
|
|
|
|
|
SV *self |
|
697
|
|
|
|
|
|
|
UV slot |
|
698
|
|
|
|
|
|
|
NV val |
|
699
|
|
|
|
|
|
|
PREINIT: |
|
700
|
7
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
701
|
|
|
|
|
|
|
CODE: |
|
702
|
7
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
703
|
7
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
704
|
7
|
|
|
|
|
|
pool_set_f64(h, slot, (double)val); |
|
705
|
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
MODULE = Data::Pool::Shared PACKAGE = Data::Pool::Shared::I32 |
|
708
|
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
710
|
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
SV * |
|
712
|
|
|
|
|
|
|
new(class, path, capacity) |
|
713
|
|
|
|
|
|
|
const char *class |
|
714
|
|
|
|
|
|
|
SV *path |
|
715
|
|
|
|
|
|
|
UV capacity |
|
716
|
|
|
|
|
|
|
PREINIT: |
|
717
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
718
|
|
|
|
|
|
|
CODE: |
|
719
|
3
|
50
|
|
|
|
|
const char *p = SvOK(path) ? SvPV_nolen(path) : NULL; |
|
720
|
3
|
|
|
|
|
|
PoolHandle *h = pool_create(p, capacity, sizeof(int32_t), POOL_VAR_I32, errbuf); |
|
721
|
3
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I32->new: %s", errbuf); |
|
722
|
3
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
723
|
|
|
|
|
|
|
OUTPUT: |
|
724
|
|
|
|
|
|
|
RETVAL |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
SV * |
|
727
|
|
|
|
|
|
|
new_memfd(class, name, capacity) |
|
728
|
|
|
|
|
|
|
const char *class |
|
729
|
|
|
|
|
|
|
const char *name |
|
730
|
|
|
|
|
|
|
UV capacity |
|
731
|
|
|
|
|
|
|
PREINIT: |
|
732
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
733
|
|
|
|
|
|
|
CODE: |
|
734
|
1
|
|
|
|
|
|
PoolHandle *h = pool_create_memfd(name, capacity, sizeof(int32_t), POOL_VAR_I32, errbuf); |
|
735
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I32->new_memfd: %s", errbuf); |
|
736
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
737
|
|
|
|
|
|
|
OUTPUT: |
|
738
|
|
|
|
|
|
|
RETVAL |
|
739
|
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
SV * |
|
741
|
|
|
|
|
|
|
new_from_fd(class, fd) |
|
742
|
|
|
|
|
|
|
const char *class |
|
743
|
|
|
|
|
|
|
int fd |
|
744
|
|
|
|
|
|
|
PREINIT: |
|
745
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
746
|
|
|
|
|
|
|
CODE: |
|
747
|
1
|
|
|
|
|
|
PoolHandle *h = pool_open_fd(fd, POOL_VAR_I32, errbuf); |
|
748
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::I32->new_from_fd: %s", errbuf); |
|
749
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
750
|
|
|
|
|
|
|
OUTPUT: |
|
751
|
|
|
|
|
|
|
RETVAL |
|
752
|
|
|
|
|
|
|
|
|
753
|
|
|
|
|
|
|
IV |
|
754
|
|
|
|
|
|
|
get(self, slot) |
|
755
|
|
|
|
|
|
|
SV *self |
|
756
|
|
|
|
|
|
|
UV slot |
|
757
|
|
|
|
|
|
|
PREINIT: |
|
758
|
5
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
CODE: |
|
760
|
5
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
761
|
5
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
762
|
5
|
50
|
|
|
|
|
RETVAL = (IV)pool_get_i32(h, slot); |
|
763
|
|
|
|
|
|
|
OUTPUT: |
|
764
|
|
|
|
|
|
|
RETVAL |
|
765
|
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
void |
|
767
|
|
|
|
|
|
|
set(self, slot, val) |
|
768
|
|
|
|
|
|
|
SV *self |
|
769
|
|
|
|
|
|
|
UV slot |
|
770
|
|
|
|
|
|
|
IV val |
|
771
|
|
|
|
|
|
|
PREINIT: |
|
772
|
6
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
773
|
|
|
|
|
|
|
CODE: |
|
774
|
6
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
775
|
6
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
776
|
6
|
|
|
|
|
|
pool_set_i32(h, slot, (int32_t)val); |
|
777
|
|
|
|
|
|
|
|
|
778
|
|
|
|
|
|
|
bool |
|
779
|
|
|
|
|
|
|
cas(self, slot, expected, desired) |
|
780
|
|
|
|
|
|
|
SV *self |
|
781
|
|
|
|
|
|
|
UV slot |
|
782
|
|
|
|
|
|
|
IV expected |
|
783
|
|
|
|
|
|
|
IV desired |
|
784
|
|
|
|
|
|
|
PREINIT: |
|
785
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
786
|
|
|
|
|
|
|
CODE: |
|
787
|
1
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
788
|
1
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
789
|
1
|
50
|
|
|
|
|
RETVAL = pool_cas_i32(h, slot, (int32_t)expected, (int32_t)desired); |
|
790
|
|
|
|
|
|
|
OUTPUT: |
|
791
|
|
|
|
|
|
|
RETVAL |
|
792
|
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
IV |
|
794
|
|
|
|
|
|
|
cmpxchg(self, slot, expected, desired) |
|
795
|
|
|
|
|
|
|
SV *self |
|
796
|
|
|
|
|
|
|
UV slot |
|
797
|
|
|
|
|
|
|
IV expected |
|
798
|
|
|
|
|
|
|
IV desired |
|
799
|
|
|
|
|
|
|
PREINIT: |
|
800
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
CODE: |
|
802
|
2
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
803
|
2
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
804
|
2
|
50
|
|
|
|
|
RETVAL = (IV)pool_cmpxchg_i32(h, slot, (int32_t)expected, (int32_t)desired); |
|
805
|
|
|
|
|
|
|
OUTPUT: |
|
806
|
|
|
|
|
|
|
RETVAL |
|
807
|
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
IV |
|
809
|
|
|
|
|
|
|
xchg(self, slot, val) |
|
810
|
|
|
|
|
|
|
SV *self |
|
811
|
|
|
|
|
|
|
UV slot |
|
812
|
|
|
|
|
|
|
IV val |
|
813
|
|
|
|
|
|
|
PREINIT: |
|
814
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
815
|
|
|
|
|
|
|
CODE: |
|
816
|
1
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
817
|
1
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
818
|
1
|
50
|
|
|
|
|
RETVAL = (IV)pool_xchg_i32(h, slot, (int32_t)val); |
|
819
|
|
|
|
|
|
|
OUTPUT: |
|
820
|
|
|
|
|
|
|
RETVAL |
|
821
|
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
IV |
|
823
|
|
|
|
|
|
|
add(self, slot, delta) |
|
824
|
|
|
|
|
|
|
SV *self |
|
825
|
|
|
|
|
|
|
UV slot |
|
826
|
|
|
|
|
|
|
IV delta |
|
827
|
|
|
|
|
|
|
PREINIT: |
|
828
|
2
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
829
|
|
|
|
|
|
|
CODE: |
|
830
|
2
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
831
|
2
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
832
|
2
|
50
|
|
|
|
|
RETVAL = (IV)pool_add_i32(h, slot, (int32_t)delta); |
|
833
|
|
|
|
|
|
|
OUTPUT: |
|
834
|
|
|
|
|
|
|
RETVAL |
|
835
|
|
|
|
|
|
|
|
|
836
|
|
|
|
|
|
|
IV |
|
837
|
|
|
|
|
|
|
incr(self, slot) |
|
838
|
|
|
|
|
|
|
SV *self |
|
839
|
|
|
|
|
|
|
UV slot |
|
840
|
|
|
|
|
|
|
PREINIT: |
|
841
|
0
|
0
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
842
|
|
|
|
|
|
|
CODE: |
|
843
|
0
|
0
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
844
|
0
|
0
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
845
|
0
|
0
|
|
|
|
|
RETVAL = (IV)pool_add_i32(h, slot, 1); |
|
846
|
|
|
|
|
|
|
OUTPUT: |
|
847
|
|
|
|
|
|
|
RETVAL |
|
848
|
|
|
|
|
|
|
|
|
849
|
|
|
|
|
|
|
IV |
|
850
|
|
|
|
|
|
|
decr(self, slot) |
|
851
|
|
|
|
|
|
|
SV *self |
|
852
|
|
|
|
|
|
|
UV slot |
|
853
|
|
|
|
|
|
|
PREINIT: |
|
854
|
0
|
0
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
855
|
|
|
|
|
|
|
CODE: |
|
856
|
0
|
0
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
857
|
0
|
0
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
858
|
0
|
0
|
|
|
|
|
RETVAL = (IV)pool_add_i32(h, slot, -1); |
|
859
|
|
|
|
|
|
|
OUTPUT: |
|
860
|
|
|
|
|
|
|
RETVAL |
|
861
|
|
|
|
|
|
|
|
|
862
|
|
|
|
|
|
|
|
|
863
|
|
|
|
|
|
|
MODULE = Data::Pool::Shared PACKAGE = Data::Pool::Shared::Str |
|
864
|
|
|
|
|
|
|
|
|
865
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
|
866
|
|
|
|
|
|
|
|
|
867
|
|
|
|
|
|
|
SV * |
|
868
|
|
|
|
|
|
|
new(class, path, capacity, max_len) |
|
869
|
|
|
|
|
|
|
const char *class |
|
870
|
|
|
|
|
|
|
SV *path |
|
871
|
|
|
|
|
|
|
UV capacity |
|
872
|
|
|
|
|
|
|
UV max_len |
|
873
|
|
|
|
|
|
|
PREINIT: |
|
874
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
875
|
|
|
|
|
|
|
CODE: |
|
876
|
4
|
50
|
|
|
|
|
if (max_len == 0) croak("Data::Pool::Shared::Str->new: max_len must be > 0"); |
|
877
|
4
|
50
|
|
|
|
|
if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t))) |
|
878
|
0
|
|
|
|
|
|
croak("Data::Pool::Shared::Str->new: max_len too large"); |
|
879
|
4
|
|
|
|
|
|
uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len); |
|
880
|
4
|
100
|
|
|
|
|
const char *p = SvOK(path) ? SvPV_nolen(path) : NULL; |
|
881
|
4
|
|
|
|
|
|
PoolHandle *h = pool_create(p, capacity, elem_size, POOL_VAR_STR, errbuf); |
|
882
|
4
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::Str->new: %s", errbuf); |
|
883
|
4
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
884
|
|
|
|
|
|
|
OUTPUT: |
|
885
|
|
|
|
|
|
|
RETVAL |
|
886
|
|
|
|
|
|
|
|
|
887
|
|
|
|
|
|
|
SV * |
|
888
|
|
|
|
|
|
|
new_memfd(class, name, capacity, max_len) |
|
889
|
|
|
|
|
|
|
const char *class |
|
890
|
|
|
|
|
|
|
const char *name |
|
891
|
|
|
|
|
|
|
UV capacity |
|
892
|
|
|
|
|
|
|
UV max_len |
|
893
|
|
|
|
|
|
|
PREINIT: |
|
894
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
895
|
|
|
|
|
|
|
CODE: |
|
896
|
1
|
50
|
|
|
|
|
if (max_len == 0) croak("Data::Pool::Shared::Str->new_memfd: max_len must be > 0"); |
|
897
|
1
|
50
|
|
|
|
|
if (max_len > (UV)(UINT32_MAX - sizeof(uint32_t))) |
|
898
|
0
|
|
|
|
|
|
croak("Data::Pool::Shared::Str->new_memfd: max_len too large"); |
|
899
|
1
|
|
|
|
|
|
uint32_t elem_size = (uint32_t)(sizeof(uint32_t) + max_len); |
|
900
|
1
|
|
|
|
|
|
PoolHandle *h = pool_create_memfd(name, capacity, elem_size, POOL_VAR_STR, errbuf); |
|
901
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::Str->new_memfd: %s", errbuf); |
|
902
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
903
|
|
|
|
|
|
|
OUTPUT: |
|
904
|
|
|
|
|
|
|
RETVAL |
|
905
|
|
|
|
|
|
|
|
|
906
|
|
|
|
|
|
|
SV * |
|
907
|
|
|
|
|
|
|
new_from_fd(class, fd) |
|
908
|
|
|
|
|
|
|
const char *class |
|
909
|
|
|
|
|
|
|
int fd |
|
910
|
|
|
|
|
|
|
PREINIT: |
|
911
|
|
|
|
|
|
|
char errbuf[POOL_ERR_BUFLEN]; |
|
912
|
|
|
|
|
|
|
CODE: |
|
913
|
1
|
|
|
|
|
|
PoolHandle *h = pool_open_fd(fd, POOL_VAR_STR, errbuf); |
|
914
|
1
|
50
|
|
|
|
|
if (!h) croak("Data::Pool::Shared::Str->new_from_fd: %s", errbuf); |
|
915
|
1
|
|
|
|
|
|
MAKE_OBJ(class, h); |
|
916
|
|
|
|
|
|
|
OUTPUT: |
|
917
|
|
|
|
|
|
|
RETVAL |
|
918
|
|
|
|
|
|
|
|
|
919
|
|
|
|
|
|
|
SV * |
|
920
|
|
|
|
|
|
|
get(self, slot) |
|
921
|
|
|
|
|
|
|
SV *self |
|
922
|
|
|
|
|
|
|
UV slot |
|
923
|
|
|
|
|
|
|
PREINIT: |
|
924
|
11
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
925
|
|
|
|
|
|
|
CODE: |
|
926
|
11
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
927
|
11
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
928
|
11
|
|
|
|
|
|
uint32_t len = pool_get_str_len(h, slot); |
|
929
|
11
|
|
|
|
|
|
RETVAL = newSVpvn(pool_get_str_ptr(h, slot), len); |
|
930
|
|
|
|
|
|
|
OUTPUT: |
|
931
|
|
|
|
|
|
|
RETVAL |
|
932
|
|
|
|
|
|
|
|
|
933
|
|
|
|
|
|
|
void |
|
934
|
|
|
|
|
|
|
set(self, slot, val) |
|
935
|
|
|
|
|
|
|
SV *self |
|
936
|
|
|
|
|
|
|
UV slot |
|
937
|
|
|
|
|
|
|
SV *val |
|
938
|
|
|
|
|
|
|
PREINIT: |
|
939
|
8
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
940
|
|
|
|
|
|
|
CODE: |
|
941
|
8
|
50
|
|
|
|
|
CHECK_SLOT(h, slot); |
|
942
|
8
|
50
|
|
|
|
|
CHECK_ALLOCATED(h, slot); |
|
943
|
|
|
|
|
|
|
STRLEN len; |
|
944
|
8
|
|
|
|
|
|
const char *str = SvPV(val, len); |
|
945
|
8
|
|
|
|
|
|
pool_set_str(h, slot, str, (uint32_t)len); |
|
946
|
|
|
|
|
|
|
|
|
947
|
|
|
|
|
|
|
UV |
|
948
|
|
|
|
|
|
|
max_len(self) |
|
949
|
|
|
|
|
|
|
SV *self |
|
950
|
|
|
|
|
|
|
PREINIT: |
|
951
|
1
|
50
|
|
|
|
|
EXTRACT_POOL(self); |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
952
|
|
|
|
|
|
|
CODE: |
|
953
|
1
|
50
|
|
|
|
|
RETVAL = h->hdr->elem_size - sizeof(uint32_t); |
|
954
|
|
|
|
|
|
|
OUTPUT: |
|
955
|
|
|
|
|
|
|
RETVAL |