Shared.xs

filter: Statementstmt 97.9% 433 / 442 Branchbran 56.4% 445 / 788 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 71.3% 878 / 1230 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« queue.h ↑ Summary blib/lib/Data/Queue/Shared/Int.pm »
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 "queue.h"
8  
9 /* Narrow a Perl string length to the uint32 wire width WITHOUT silent truncation:
10 * a length that doesn't fit maps to UINT32_MAX so the downstream < 2 GiB size
11 * check croaks, instead of the value wrapping to a small, wrongly-accepted length.
12 * Defined unconditionally (NOT inside the XS::Parse::Keyword guard) so it exists
13 * even where that optional dependency is absent. */
14 #define LEN32(len) ((len) > (STRLEN)0xFFFFFFFFU ? 0xFFFFFFFFU : (uint32_t)(len))
15  
16 #ifdef HAVE_XS_PARSE_KEYWORD
17 #include "XSParseKeyword.h"
18  
19 /* ---- Keyword build functions (compile keywords to direct ENTERSUB ops) ---- */
20  
21 15 static int build_kw_1arg(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata) {
22 (void)nargs;
23 15 const char *func = (const char *)hookdata;
24 15 OP *q_op = args[0]->op;
25 15 OP *cvref = newCVREF(0, newGVOP(OP_GV, 0, gv_fetchpv(func, GV_ADD, SVt_PVCV)));
26 15 *out = op_convert_list(OP_ENTERSUB, OPf_STACKED,
27 op_append_elem(OP_LIST, q_op, cvref));
28 15 return KEYWORD_PLUGIN_EXPR;
29 }
30  
31 8 static int build_kw_2arg(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata) {
32 (void)nargs;
33 8 const char *func = (const char *)hookdata;
34 8 OP *q_op = args[0]->op;
35 8 OP *val_op = args[1]->op;
36 8 OP *cvref = newCVREF(0, newGVOP(OP_GV, 0, gv_fetchpv(func, GV_ADD, SVt_PVCV)));
37 8 OP *arglist = op_append_elem(OP_LIST, q_op, val_op);
38 8 arglist = op_append_elem(OP_LIST, arglist, cvref);
39 8 *out = op_convert_list(OP_ENTERSUB, OPf_STACKED, arglist);
40 8 return KEYWORD_PLUGIN_EXPR;
41 }
42  
43 static const struct XSParseKeywordPieceType pieces_1expr[] = {
44 XPK_TERMEXPR, {0}
45 };
46  
47 static const struct XSParseKeywordPieceType pieces_2expr[] = {
48 XPK_TERMEXPR, XPK_COMMA, XPK_TERMEXPR, {0}
49 };
50  
51 /* Hook definition macro: q_<variant>_<op> */
52 #define DEFINE_Q_KW(variant, PKG, kw, nargs, builder) \
53 static const struct XSParseKeywordHooks hooks_q_##variant##_##kw = { \
54 .flags = XPK_FLAG_EXPR, \
55 .permit_hintkey = "Data::Queue::Shared::" PKG "/q_" #variant "_" #kw, \
56 .pieces = pieces_##nargs##expr, \
57 .build = builder, \
58 };
59  
60 /* Int keywords */
61 DEFINE_Q_KW(int, "Int", push, 2, build_kw_2arg)
62 DEFINE_Q_KW(int, "Int", pop, 1, build_kw_1arg)
63 DEFINE_Q_KW(int, "Int", peek, 1, build_kw_1arg)
64 DEFINE_Q_KW(int, "Int", size, 1, build_kw_1arg)
65  
66 /* Int32 keywords */
67 DEFINE_Q_KW(int32, "Int32", push, 2, build_kw_2arg)
68 DEFINE_Q_KW(int32, "Int32", pop, 1, build_kw_1arg)
69 DEFINE_Q_KW(int32, "Int32", peek, 1, build_kw_1arg)
70 DEFINE_Q_KW(int32, "Int32", size, 1, build_kw_1arg)
71  
72 /* Int16 keywords */
73 DEFINE_Q_KW(int16, "Int16", push, 2, build_kw_2arg)
74 DEFINE_Q_KW(int16, "Int16", pop, 1, build_kw_1arg)
75 DEFINE_Q_KW(int16, "Int16", peek, 1, build_kw_1arg)
76 DEFINE_Q_KW(int16, "Int16", size, 1, build_kw_1arg)
77  
78 /* Str keywords */
79 DEFINE_Q_KW(str, "Str", push, 2, build_kw_2arg)
80 DEFINE_Q_KW(str, "Str", pop, 1, build_kw_1arg)
81 DEFINE_Q_KW(str, "Str", peek, 1, build_kw_1arg)
82 DEFINE_Q_KW(str, "Str", size, 1, build_kw_1arg)
83  
84 #define REGISTER_Q_KW(variant, kw, func_name) \
85 register_xs_parse_keyword("q_" #variant "_" #kw, \
86 &hooks_q_##variant##_##kw, (void*)func_name)
87  
88 #endif /* HAVE_XS_PARSE_KEYWORD */
89  
90 #define EXTRACT_HANDLE(classname, sv) \
91 if (!sv_isobject(sv) || !sv_derived_from(sv, classname)) \
92 croak("Expected a %s object", classname); \
93 QueueHandle *h = INT2PTR(QueueHandle*, SvIV(SvRV(sv))); \
94 if (!h) croak("Attempted to use a destroyed %s object", classname); \
95 QueueHandle *h0 = h; PERL_UNUSED_VAR(h0); \
96 sv_2mortal(SvREFCNT_inc(SvRV(sv)))
97  
98 /* Re-read the handle after a call that can run Perl code (tied/overloaded
99 * argument magic, tied-array fetches). That code may call $obj->DESTROY
100 * explicitly, which frees the handle and zeroes the IV; EXTRACT_HANDLE's
101 * mortal pins the referent only against refcount-driven destruction, not an
102 * explicit DESTROY, so the local h would dangle. Used only where magic
103 * can actually intervene between EXTRACT_HANDLE and the first use of h. */
104 #define REEXTRACT_HANDLE(classname, sv) \
105 if (!SvROK(sv)) \
106 croak("%s object was replaced during the call", classname); \
107 h = INT2PTR(QueueHandle*, SvIV(SvRV(sv))); \
108 if (h != h0) croak("%s object replaced or destroyed during the call", classname)
109  
110 #define MAKE_OBJ(class, ptr) \
111 SV *ref = newRV_noinc(newSViv(PTR2IV(ptr))); \
112 sv_bless(ref, gv_stashpv(class, GV_ADD)); \
113 RETVAL = ref
114  
115 #define OPT_ARG(n) (items > (n) && (SvGETMAGIC(ST(n)), SvOK(ST(n))))
116 #define STR_TOO_BIG "Data::Queue::Shared::Str: string too big (exceeds arena capacity or 2GB limit)"
117 #define STR_OOM "Data::Queue::Shared::Str: out of memory"
118  
119 /* $! after a Str operation that did nothing: its reason, or 0 for a plain full or empty queue. */
120 4908 static void str_errno(QueueHandle *h, int r) {
121 4908 ▶ errno = r == QUEUE_FAILED ? h->fail_errno : 0;
Branch: 1 branch
BranchTrueFalseTotal
errno = r == QUEUE_FAILED ? h->fail_errno : 0; 16 4892 4908
122 4908 }
123  
124 21198 static bool str_ok(pTHX_ QueueHandle *h, int r) {
125 21198 ▶ if (r == -2) croak(STR_TOO_BIG);
Branch: 1 branch
BranchTrueFalseTotal
if (r == -2) croak(STR_TOO_BIG); 0 21198 21198
126 21198 ▶ if (r != 1) str_errno(h, r);
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) str_errno(h, r); 2311 18887 21198
127 21198 return r == 1;
128 }
129  
130 20364 static SV *str_sv(pTHX_ QueueHandle *h, int r, const char *str, uint32_t len, bool utf8) {
131 20364 ▶ if (r == -1) croak(STR_OOM);
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) croak(STR_OOM); 0 20364 20364
132 20364 ▶ if (r != 1) { str_errno(h, r); return &PL_sv_undef; }
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) { str_errno(h, r); return &PL_sv_undef; } 2593 17771 20364
133 17771 SV *sv = newSVpvn(str, len);
134 17771 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 5 17766 17771
135 17771 return sv;
136 }
137  
138 typedef struct { char *buf; uint32_t len; bool utf8; } StrItem;
139  
140 /* Pops up to count values under one hold of the lock, ending before one that would take the
141 * batch past max_bytes; unless a value was taken before, the first one always comes. Copies
142 * them out so that no Perl allocation, which can croak, happens under the lock. */
143 38 static StrItem *str_pop_batch(pTHX_ QueueHandle *h, UV count, uint64_t max_bytes,
144 uint64_t bytes, int taken, UV *n_out) {
145 38 *n_out = 0;
146 38 ▶ if (count > h->capacity) count = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
if (count > h->capacity) count = h->capacity; 13 25 38
147 38 ▶ if (!count) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!count) return NULL; 2 36 38
148 36 StrItem *it = (StrItem *)malloc((size_t)count * sizeof *it);
149 36 ▶ if (!it) croak(STR_OOM);
Branch: 1 branch
BranchTrueFalseTotal
if (!it) croak(STR_OOM); 0 36 36
150 36 ▶ if (!queue_str_lock(h)) { free(it); str_errno(h, QUEUE_FAILED); return NULL; }
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_str_lock(h)) { free(it); str_errno(h, QUEUE_FAILED); return NULL; } 2 34 36
151 34 UV n = 0;
152 34 int r = 1;
153 98 ▶ while (n < count && !((n || taken) && bytes + queue_str_front_len(h) > max_bytes)) {
Branch: 4 branches
BranchTrueFalseTotal
while (n < count && !((n || taken) && bytes + queue_str_front_len(h) > max_bytes)) { 88 10 98
while (n < count && !((n || taken) && bytes + queue_str_front_len(h) > max_bytes)) { 34 54 88
while (n < count && !((n || taken) && bytes + queue_str_front_len(h) > max_bytes)) { 25 9 34
while (n < count && !((n || taken) && bytes + queue_str_front_len(h) > max_bytes)) { 56 7 63
154 const char *str; uint32_t len; bool utf8;
155 81 r = queue_str_pop_locked(h, &str, &len, &utf8);
156 81 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 17 64 81
157 64 ▶ char *c = (char *)malloc(len ? len : 1);
Branch: 1 branch
BranchTrueFalseTotal
char *c = (char *)malloc(len ? len : 1); 64 0 64
158 64 ▶ if (!c) { r = -1; break; }
Branch: 1 branch
BranchTrueFalseTotal
if (!c) { r = -1; break; } 0 64 64
159 64 memcpy(c, str, len);
160 64 it[n].buf = c; it[n].len = len; it[n].utf8 = utf8;
161 64 n++;
162 64 bytes += len;
163 }
164 34 ▶ uint32_t wake = n ? queue_str_producer_wake_count(h->hdr, (uint32_t)n) : 0;
Branch: 1 branch
BranchTrueFalseTotal
uint32_t wake = n ? queue_str_producer_wake_count(h->hdr, (uint32_t)n) : 0; 28 6 34
165 34 queue_mutex_unlock(h->hdr);
166 34 ▶ if (wake) queue_wake_producers_n(h->hdr, wake);
Branch: 1 branch
BranchTrueFalseTotal
if (wake) queue_wake_producers_n(h->hdr, wake); 28 6 34
167 34 ▶ if (r == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) { 0 34 34
168 0 ▶ while (n) free(it[--n].buf);
Branch: 1 branch
BranchTrueFalseTotal
while (n) free(it[--n].buf); 0 0 0
169 0 free(it);
170 0 croak(STR_OOM);
171 }
172 34 ▶ if (!n) errno = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!n) errno = 0; 6 28 34
173 34 *n_out = n;
174 34 return it;
175 }
176  
177 38 static SV **str_push_items(pTHX_ SV **sp, StrItem *it, UV n) {
178 38 ▶ EXTEND(sp, (SSize_t)n);
Branch: 2 branches
BranchTrueFalseTotal
EXTEND(sp, (SSize_t)n); 38 0 38
EXTEND(sp, (SSize_t)n); 0 38 38
179 102 ▶ for (UV i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < n; i++) { 64 38 102
180 64 SV *sv = newSVpvn(it[i].buf, it[i].len);
181 64 ▶ if (it[i].utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (it[i].utf8) SvUTF8_on(sv); 2 62 64
182 64 PUSHs(sv_2mortal(sv));
183 64 free(it[i].buf);
184 }
185 38 free(it);
186 38 return sp;
187 }
188  
189 MODULE = Data::Queue::Shared PACKAGE = Data::Queue::Shared::Int
190  
191 PROTOTYPES: DISABLE
192  
193 BOOT:
194 #ifdef HAVE_XS_PARSE_KEYWORD
195 25 boot_xs_parse_keyword(0.50);
196 25 sv_setiv(get_sv("Data::Queue::Shared::HAVE_KEYWORDS", GV_ADD), 1);
197 25 REGISTER_Q_KW(int, push, "Data::Queue::Shared::Int::push");
198 25 REGISTER_Q_KW(int, pop, "Data::Queue::Shared::Int::pop");
199 25 REGISTER_Q_KW(int, peek, "Data::Queue::Shared::Int::peek");
200 25 REGISTER_Q_KW(int, size, "Data::Queue::Shared::Int::size");
201 25 REGISTER_Q_KW(int32, push, "Data::Queue::Shared::Int32::push");
202 25 REGISTER_Q_KW(int32, pop, "Data::Queue::Shared::Int32::pop");
203 25 REGISTER_Q_KW(int32, peek, "Data::Queue::Shared::Int32::peek");
204 25 REGISTER_Q_KW(int32, size, "Data::Queue::Shared::Int32::size");
205 25 REGISTER_Q_KW(int16, push, "Data::Queue::Shared::Int16::push");
206 25 REGISTER_Q_KW(int16, pop, "Data::Queue::Shared::Int16::pop");
207 25 REGISTER_Q_KW(int16, peek, "Data::Queue::Shared::Int16::peek");
208 25 REGISTER_Q_KW(int16, size, "Data::Queue::Shared::Int16::size");
209 25 REGISTER_Q_KW(str, push, "Data::Queue::Shared::Str::push");
210 25 REGISTER_Q_KW(str, pop, "Data::Queue::Shared::Str::pop");
211 25 REGISTER_Q_KW(str, peek, "Data::Queue::Shared::Str::peek");
212 25 REGISTER_Q_KW(str, size, "Data::Queue::Shared::Str::size");
213 #endif
214 /* XSMARKER: end of BOOT -- INCLUDE_COMMAND regex must strip BOOT from generated sections */
215  
216 SV *
217 new(class, path, capacity, ...)
218 const char *class
219 SV *path
220 UV capacity
221 PREINIT:
222 char errbuf[QUEUE_ERR_BUFLEN];
223 CODE:
224 109 ▶ const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL;
Branch: 3 branches
BranchTrueFalseTotal
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 63 63
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 0 0
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 46 17 63
225 /* Optional 4th arg: file mode for a new file-backed segment (default 0600,
226 * owner-only); pass e.g. 0660 to opt into cross-user sharing. */
227 63 ▶ mode_t fmode = OPT_ARG(3) ? (mode_t)SvUV_nomg(ST(3)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = OPT_ARG(3) ? (mode_t)SvUV_nomg(ST(3)) : 0600; 0 63 63
mode_t fmode = OPT_ARG(3) ? (mode_t)SvUV_nomg(ST(3)) : 0600; 0 0 0
mode_t fmode = OPT_ARG(3) ? (mode_t)SvUV_nomg(ST(3)) : 0600; 0 0 0
mode_t fmode = OPT_ARG(3) ? (mode_t)SvUV_nomg(ST(3)) : 0600; 0 0 0
228 63 QueueHandle *h = queue_create(p, (uint32_t)capacity, QUEUE_MODE_INT, 0, fmode, errbuf);
229 63 ▶ if (!h) croak("Data::Queue::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 8 55 63
if (!h) croak("Data::Queue::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 8 0 8
230 55 MAKE_OBJ(class, h);
231 OUTPUT:
232 RETVAL
233  
234 SV *
235 new_memfd(class, name, capacity)
236 const char *class
237 const char *name
238 UV capacity
239 PREINIT:
240 char errbuf[QUEUE_ERR_BUFLEN];
241 CODE:
242 6 QueueHandle *h = queue_create_memfd(name, (uint32_t)capacity, QUEUE_MODE_INT, 0, errbuf);
243 6 ▶ if (!h) croak("Data::Queue::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 6 6
if (!h) croak("Data::Queue::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
244 6 MAKE_OBJ(class, h);
245 OUTPUT:
246 RETVAL
247  
248 SV *
249 new_from_fd(class, fd)
250 const char *class
251 int fd
252 PREINIT:
253 char errbuf[QUEUE_ERR_BUFLEN];
254 CODE:
255 2 QueueHandle *h = queue_open_fd(fd, QUEUE_MODE_INT, errbuf);
256 2 ▶ if (!h) croak("Data::Queue::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 1 2
if (!h) croak("Data::Queue::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
257 1 MAKE_OBJ(class, h);
258 OUTPUT:
259 RETVAL
260  
261 IV
262 memfd(self)
263 SV *self
264 PREINIT:
265 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
266 CODE:
267 2 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 2 2
268 OUTPUT:
269 RETVAL
270  
271 void
272 DESTROY(self)
273 SV *self
274 CODE:
275 62 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Int")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Int")) return; 62 0 62
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Int")) return; 0 62 62
276 62 QueueHandle *h = INT2PTR(QueueHandle*, SvIV(SvRV(self)));
277 62 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 62 62
278 62 sv_setiv(SvRV(self), 0);
279 62 queue_destroy(h);
280  
281 bool
282 push(self, value)
283 SV *self
284 IV value
285 PREINIT:
286 210 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 210 0 210
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 210 210
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 210 210
287 CODE:
288 210 ▶ RETVAL = queue_int_try_push(h, (int64_t)value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = queue_int_try_push(h, (int64_t)value); 206 4 210
289 OUTPUT:
290 RETVAL
291  
292 SV *
293 pop(self)
294 SV *self
295 PREINIT:
296 105 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 105 0 105
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 105 105
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 105 105
297 int64_t value;
298 CODE:
299 105 ▶ if (queue_int_try_pop(h, &value))
Branch: 1 branch
BranchTrueFalseTotal
if (queue_int_try_pop(h, &value)) 101 4 105
300 101 RETVAL = newSViv((IV)value);
301 else
302 4 RETVAL = &PL_sv_undef;
303 OUTPUT:
304 RETVAL
305  
306 bool
307 push_wait(self, value, ...)
308 SV *self
309 IV value
310 PREINIT:
311 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
312 2 double timeout = -1;
313 CODE:
314 2 ▶ if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 2 0 2
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 2 2
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 0 0
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 2 0 2
315 2 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
316 2 ▶ RETVAL = queue_int_push_wait(h, (int64_t)value, timeout);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = queue_int_push_wait(h, (int64_t)value, timeout); 1 1 2
317 OUTPUT:
318 RETVAL
319  
320 SV *
321 pop_wait(self, ...)
322 SV *self
323 PREINIT:
324 104 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 104 0 104
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 104 104
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 104 104
325 104 double timeout = -1;
326 int64_t value;
327 CODE:
328 104 ▶ if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 104 0 104
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 104 104
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 0 0
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 104 0 104
329 104 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 104 104
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 104 104
330 104 ▶ if (queue_int_pop_wait(h, &value, timeout))
Branch: 1 branch
BranchTrueFalseTotal
if (queue_int_pop_wait(h, &value, timeout)) 103 1 104
331 103 RETVAL = newSViv((IV)value);
332 else
333 1 RETVAL = &PL_sv_undef;
334 OUTPUT:
335 RETVAL
336  
337 UV
338 push_multi(self, ...)
339 SV *self
340 PREINIT:
341 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
342 CODE:
343 3 uint32_t count = items - 1;
344 3 uint32_t pushed = 0;
345 13 ▶ for (uint32_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) { 11 2 13
346 11 int64_t v = (int64_t)SvIV(ST(i + 1));
347 11 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 11 11
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 11 11
348 11 ▶ if (!queue_int_try_push(h, v)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_int_try_push(h, v)) break; 1 10 11
349 10 pushed++;
350 }
351  
352 3 ▶ RETVAL = pushed;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pushed; 0 3 3
353 OUTPUT:
354 RETVAL
355  
356 void
357 pop_multi(self, count)
358 SV *self
359 UV count
360 PREINIT:
361 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
362 int64_t value;
363 PPCODE:
364 3 ▶ if (count > h->capacity) count = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
if (count > h->capacity) count = h->capacity; 2 1 3
365 16 ▶ for (UV i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < count; i++) { 14 2 16
366 14 ▶ if (!queue_int_try_pop(h, &value)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_int_try_pop(h, &value)) break; 1 13 14
367 13 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 13 13
368 }
369  
370 UV
371 size(self)
372 SV *self
373 PREINIT:
374 19 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 19 0 19
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 19 19
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 19 19
375 CODE:
376 19 RETVAL = (UV)queue_int_size(h);
377 OUTPUT:
378 RETVAL
379  
380 UV
381 capacity(self)
382 SV *self
383 PREINIT:
384 9 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 9 0 9
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 9 9
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 9 9
385 CODE:
386 9 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 0 9 9
387 OUTPUT:
388 RETVAL
389  
390 bool
391 is_empty(self)
392 SV *self
393 PREINIT:
394 7 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 7 0 7
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 7 7
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 7 7
395 CODE:
396 7 ▶ RETVAL = (queue_int_size(h) == 0);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (queue_int_size(h) == 0); 6 1 7
397 OUTPUT:
398 RETVAL
399  
400 bool
401 is_full(self)
402 SV *self
403 PREINIT:
404 4 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 4 0 4
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
405 CODE:
406 4 ▶ RETVAL = (queue_int_size(h) >= h->capacity);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (queue_int_size(h) >= h->capacity); 2 2 4
407 OUTPUT:
408 RETVAL
409  
410 void
411 clear(self)
412 SV *self
413 PREINIT:
414 5 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 5 0 5
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 5 5
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 5 5
415 CODE:
416 5 queue_int_clear(h);
417  
418 void
419 unlink(self_or_class, ...)
420 SV *self_or_class
421 CODE:
422 const char *path;
423 8 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Int")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Int")) { 7 1 8
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Int")) { 7 0 7
424 7 QueueHandle *h = INT2PTR(QueueHandle*, SvIV(SvRV(self_or_class)));
425 7 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 7 7
426 7 path = h->path;
427 } else {
428 1 ▶ if (items < 2) croak("Usage: Data::Queue::Shared::Int->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::Queue::Shared::Int->unlink($path)"); 0 1 1
429 2 path = SvPV_nolen(ST(1));
430 }
431 8 ▶ if (!path) croak("cannot unlink anonymous or memfd queue");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd queue"); 2 6 8
432 6 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 6 6
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
433 0 croak("unlink(%s): %s", path, strerror(errno));
434  
435 SV *
436 path(self)
437 SV *self
438 PREINIT:
439 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
440 CODE:
441 3 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 1 2 3
442 OUTPUT:
443 RETVAL
444  
445 SV *
446 stats(self)
447 SV *self
448 PREINIT:
449 7 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 7 0 7
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 7 7
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 7 7
450 CODE:
451 7 HV *hv = newHV();
452 7 QueueHeader *hdr = h->hdr;
453 7 hv_store(hv, "size", 4, newSVuv((UV)queue_int_size(h)), 0);
454 7 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
455 7 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
456 7 hv_store(hv, "push_ok", 7, newSVuv((UV)__atomic_load_n(&hdr->stat_push_ok, __ATOMIC_RELAXED)), 0);
457 7 hv_store(hv, "pop_ok", 6, newSVuv((UV)__atomic_load_n(&hdr->stat_pop_ok, __ATOMIC_RELAXED)), 0);
458 7 hv_store(hv, "push_full", 9, newSVuv((UV)__atomic_load_n(&hdr->stat_push_full, __ATOMIC_RELAXED)), 0);
459 7 hv_store(hv, "pop_empty", 9, newSVuv((UV)__atomic_load_n(&hdr->stat_pop_empty, __ATOMIC_RELAXED)), 0);
460 7 hv_store(hv, "recoveries", 10, newSVuv((UV)__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
461 7 hv_store(hv, "push_waiters", 12, newSVuv((UV)__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED)), 0);
462 7 hv_store(hv, "pop_waiters", 11, newSVuv((UV)__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED)), 0);
463 7 RETVAL = newRV_noinc((SV *)hv);
464 OUTPUT:
465 RETVAL
466  
467 SV *
468 peek(self)
469 SV *self
470 PREINIT:
471 10 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 10 0 10
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 10 10
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 10 10
472 int64_t value;
473 CODE:
474 10 ▶ if (queue_int_peek(h, &value))
Branch: 1 branch
BranchTrueFalseTotal
if (queue_int_peek(h, &value)) 7 3 10
475 7 RETVAL = newSViv((IV)value);
476 else
477 3 RETVAL = &PL_sv_undef;
478 OUTPUT:
479 RETVAL
480  
481 void
482 drain(self, ...)
483 SV *self
484 PREINIT:
485 12 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 12 0 12
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 12 12
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 12 12
486 int64_t value;
487 uint32_t max_count;
488 PPCODE:
489 12 ▶ max_count = OPT_ARG(1) ? (uint32_t)SvUV_nomg(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = OPT_ARG(1) ? (uint32_t)SvUV_nomg(ST(1)) : UINT32_MAX; 1 11 12
max_count = OPT_ARG(1) ? (uint32_t)SvUV_nomg(ST(1)) : UINT32_MAX; 0 1 1
max_count = OPT_ARG(1) ? (uint32_t)SvUV_nomg(ST(1)) : UINT32_MAX; 0 0 0
max_count = OPT_ARG(1) ? (uint32_t)SvUV_nomg(ST(1)) : UINT32_MAX; 1 0 1
490 12 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 12 12
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 12 12
491 66 ▶ while (max_count-- > 0 && queue_int_try_pop(h, &value))
Branch: 2 branches
BranchTrueFalseTotal
while (max_count-- > 0 && queue_int_try_pop(h, &value)) 65 1 66
while (max_count-- > 0 && queue_int_try_pop(h, &value)) 54 11 65
492 54 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 54 54
493  
494 void
495 pop_wait_multi(self, count, ...)
496 SV *self
497 UV count
498 PREINIT:
499 4 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 4 0 4
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
500 4 double timeout = -1;
501 int64_t value;
502 PPCODE:
503 4 ▶ if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 4 0 4
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 4 4
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 0 0
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 4 0 4
504 4 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 4 4
505 4 ▶ if (count > h->capacity) count = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
if (count > h->capacity) count = h->capacity; 0 4 4
506 4 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 1 3 4
507 /* Block until at least 1 */
508 3 ▶ if (!queue_int_pop_wait(h, &value, timeout)) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_int_pop_wait(h, &value, timeout)) XSRETURN(0); 1 2 3
509 2 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 2 2
510 /* Grab up to count-1 more non-blocking */
511 8 ▶ for (UV i = 1; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 1; i < count; i++) { 8 0 8
512 8 ▶ if (!queue_int_try_pop(h, &value)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_int_try_pop(h, &value)) break; 2 6 8
513 6 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 6 6
514 }
515  
516 UV
517 push_wait_multi(self, timeout, ...)
518 SV *self
519 double timeout
520 PREINIT:
521 5 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 5 0 5
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 5 5
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 5 5
522 CODE:
523 5 uint32_t nvalues = items - 2;
524 struct timespec dl, rem;
525 5 int has_dl = (timeout > 0);
526 5 ▶ if (has_dl) queue_make_deadline(timeout, &dl);
Branch: 1 branch
BranchTrueFalseTotal
if (has_dl) queue_make_deadline(timeout, &dl); 3 2 5
527 5 RETVAL = 0;
528 1015 ▶ for (uint32_t i = 0; i < nvalues; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < nvalues; i++) { 1012 3 1015
529 1012 double t = timeout;
530 1012 ▶ if (has_dl) {
Branch: 1 branch
BranchTrueFalseTotal
if (has_dl) { 1004 8 1012
531 2008 t = queue_remaining_time(&dl, &rem)
532 1004 ▶ ? (double)rem.tv_sec + (double)rem.tv_nsec * 1e-9 : 0;
Branch: 1 branch
BranchTrueFalseTotal
? (double)rem.tv_sec + (double)rem.tv_nsec * 1e-9 : 0; 5 999 1004
533 }
534 1012 int64_t v = (int64_t)SvIV(ST(i + 2));
535 1012 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 1012 1012
REEXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 1012 1012
536 1012 ▶ if (!queue_int_push_wait(h, v, t)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_int_push_wait(h, v, t)) break; 2 1010 1012
537 1010 RETVAL++;
538 }
539 OUTPUT:
540 RETVAL
541  
542 void
543 sync(self)
544 SV *self
545 PREINIT:
546 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
547 CODE:
548 2 ▶ if (queue_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (queue_sync(h) != 0) 0 2 2
549 0 croak("msync: %s", strerror(errno));
550  
551 IV
552 eventfd(self)
553 SV *self
554 PREINIT:
555 10 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 10 0 10
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 10 10
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 10 10
556 CODE:
557 10 RETVAL = queue_eventfd_create(h);
558 10 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 10 10
559 OUTPUT:
560 RETVAL
561  
562 void
563 eventfd_set(self, fd)
564 SV *self
565 int fd
566 PREINIT:
567 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 2 2
568 CODE:
569 2 queue_eventfd_set(h, fd);
570  
571 IV
572 fileno(self)
573 SV *self
574 PREINIT:
575 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 3 3
576 CODE:
577 3 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 0 3 3
578 OUTPUT:
579 RETVAL
580  
581 SV *
582 eventfd_consume(self)
583 SV *self
584 PREINIT:
585 11 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 11 0 11
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 11 11
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 11 11
586 CODE:
587 11 IV v = (IV)queue_eventfd_consume(h);
588 11 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 10 1 11
589 OUTPUT:
590 RETVAL
591  
592 void
593 notify(self)
594 SV *self
595 PREINIT:
596 6 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 6 0 6
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 6 6
EXTRACT_HANDLE("Data::Queue::Shared::Int", self); 0 6 6
597 CODE:
598 6 queue_notify(h);
599  
600 MODULE = Data::Queue::Shared PACKAGE = Data::Queue::Shared::Str
601  
602 SV *
603 new(class, path, capacity, ...)
604 const char *class
605 SV *path
606 UV capacity
607 PREINIT:
608 char errbuf[QUEUE_ERR_BUFLEN];
609 uint64_t arena_cap;
610 CODE:
611 69 ▶ if (items > 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) 35 34 69
612 35 arena_cap = (uint64_t)SvUV(ST(3));
613 else
614 34 arena_cap = (uint64_t)capacity * 256;
615 107 ▶ const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL;
Branch: 3 branches
BranchTrueFalseTotal
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 69 69
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 0 0 0
const char *p = (SvGETMAGIC(path), SvOK(path)) ? SvPV_nolen(path) : NULL; 38 31 69
616 /* Optional 5th arg: file mode (default 0600); arena_cap is the optional 4th. */
617 69 ▶ mode_t fmode = OPT_ARG(4) ? (mode_t)SvUV_nomg(ST(4)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = OPT_ARG(4) ? (mode_t)SvUV_nomg(ST(4)) : 0600; 0 69 69
mode_t fmode = OPT_ARG(4) ? (mode_t)SvUV_nomg(ST(4)) : 0600; 0 0 0
mode_t fmode = OPT_ARG(4) ? (mode_t)SvUV_nomg(ST(4)) : 0600; 0 0 0
mode_t fmode = OPT_ARG(4) ? (mode_t)SvUV_nomg(ST(4)) : 0600; 0 0 0
618 69 QueueHandle *h = queue_create(p, (uint32_t)capacity, QUEUE_MODE_STR, arena_cap, fmode, errbuf);
619 69 ▶ if (!h) croak("Data::Queue::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 3 66 69
if (!h) croak("Data::Queue::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 3 0 3
620 66 MAKE_OBJ(class, h);
621 OUTPUT:
622 RETVAL
623  
624 SV *
625 new_memfd(class, name, capacity, ...)
626 const char *class
627 const char *name
628 UV capacity
629 PREINIT:
630 char errbuf[QUEUE_ERR_BUFLEN];
631 uint64_t arena_cap;
632 CODE:
633 4 ▶ if (items > 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items > 3) 1 3 4
634 1 arena_cap = (uint64_t)SvUV(ST(3));
635 else
636 3 arena_cap = (uint64_t)capacity * 256;
637 4 QueueHandle *h = queue_create_memfd(name, (uint32_t)capacity, QUEUE_MODE_STR, arena_cap, errbuf);
638 4 ▶ if (!h) croak("Data::Queue::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 4 4
if (!h) croak("Data::Queue::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
639 4 MAKE_OBJ(class, h);
640 OUTPUT:
641 RETVAL
642  
643 SV *
644 new_from_fd(class, fd)
645 const char *class
646 int fd
647 PREINIT:
648 char errbuf[QUEUE_ERR_BUFLEN];
649 CODE:
650 2 QueueHandle *h = queue_open_fd(fd, QUEUE_MODE_STR, errbuf);
651 2 ▶ if (!h) croak("Data::Queue::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::Queue::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 1 2
if (!h) croak("Data::Queue::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
652 1 MAKE_OBJ(class, h);
653 OUTPUT:
654 RETVAL
655  
656 IV
657 memfd(self)
658 SV *self
659 PREINIT:
660 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
661 CODE:
662 3 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 3 3
663 OUTPUT:
664 RETVAL
665  
666 void
667 DESTROY(self)
668 SV *self
669 CODE:
670 71 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Str")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Str")) return; 71 0 71
if (!sv_isobject(self) || !sv_derived_from(self, "Data::Queue::Shared::Str")) return; 0 71 71
671 71 QueueHandle *h = INT2PTR(QueueHandle*, SvIV(SvRV(self)));
672 71 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 71 71
673 71 sv_setiv(SvRV(self), 0);
674 71 queue_destroy(h);
675  
676 bool
677 push(self, value)
678 SV *self
679 SV *value
680 PREINIT:
681 10130 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 10130 0 10130
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10130 10130
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10130 10130
682 STRLEN len;
683 CODE:
684 10130 const char *str = SvPV(value, len);
685 10130 bool utf8 = SvUTF8(value) ? true : false;
686 10130 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10130 10130
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10130 10130
687 10130 ▶ int r = queue_str_try_push(h, str, LEN32(len), utf8);
Branch: 1 branch
BranchTrueFalseTotal
int r = queue_str_try_push(h, str, LEN32(len), utf8); 10130 0 10130
688 10130 RETVAL = str_ok(aTHX_ h, r);
689 OUTPUT:
690 RETVAL
691  
692 SV *
693 pop(self)
694 SV *self
695 PREINIT:
696 10098 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 10098 0 10098
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10098 10098
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10098 10098
697 10098 const char *str = NULL;
698 10098 uint32_t len = 0;
699 10098 bool utf8 = false;
700 CODE:
701 10098 int r = queue_str_try_pop(h, &str, &len, &utf8);
702 10098 RETVAL = str_sv(aTHX_ h, r, str, len, utf8);
703 OUTPUT:
704 RETVAL
705  
706 bool
707 push_wait(self, value, ...)
708 SV *self
709 SV *value
710 PREINIT:
711 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
712 3 double timeout = -1;
713 STRLEN len;
714 CODE:
715 3 ▶ if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 3 0 3
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 3 3
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 0 0
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 3 0 3
716 3 const char *str = SvPV(value, len);
717 3 bool utf8 = SvUTF8(value) ? true : false;
718 3 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
719 3 ▶ int r = queue_str_push_wait(h, str, LEN32(len), utf8, timeout);
Branch: 1 branch
BranchTrueFalseTotal
int r = queue_str_push_wait(h, str, LEN32(len), utf8, timeout); 3 0 3
720 3 RETVAL = str_ok(aTHX_ h, r);
721 OUTPUT:
722 RETVAL
723  
724 SV *
725 pop_wait(self, ...)
726 SV *self
727 PREINIT:
728 55 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 55 0 55
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 55 55
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 55 55
729 55 double timeout = -1;
730 55 const char *str = NULL;
731 55 uint32_t len = 0;
732 55 bool utf8 = false;
733 CODE:
734 55 ▶ if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 55 0 55
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 55 55
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 0 0
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 55 0 55
735 55 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 55 55
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 55 55
736 55 int r = queue_str_pop_wait(h, &str, &len, &utf8, timeout);
737 55 RETVAL = str_sv(aTHX_ h, r, str, len, utf8);
738 OUTPUT:
739 RETVAL
740  
741 UV
742 push_multi(self, ...)
743 SV *self
744 PREINIT:
745 5 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 5 0 5
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
746 CODE:
747 5 uint32_t count = items - 1;
748 5 uint32_t pushed = 0;
749 5 ▶ if (count > h->capacity) count = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
if (count > h->capacity) count = h->capacity; 1 4 5
750 /* Extract SV data BEFORE locking: SvPV can run magic (tied/overloaded
751 * stringification) that longjmps; doing it under the process-shared
752 * mutex would abandon the lock and deadlock peers. Newx+SAVEFREEPV so a
753 * die during extraction (or the too-long croak) cannot leak args. */
754 struct qsm_arg { const char *str; STRLEN len; bool utf8; };
755 5 struct qsm_arg *args = NULL;
756 5 ▶ if (count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 0) { 5 0 5
757 5 Newx(args, count, struct qsm_arg);
758 5 SAVEFREEPV(args);
759 20 ▶ for (uint32_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) { 15 5 20
760 15 SV *sv = ST(i + 1);
761 STRLEN len;
762 15 const char *src = SvPV(sv, len); /* may run overload/tie/get-magic = arbitrary Perl */
763 15 bool utf8 = SvUTF8(sv) ? true : false;
764 /* Copy bytes into a private mortal SV NOW: a LATER element's SvPV
765 * can grow/free THIS element's PV (or reassign this scalar),
766 * dangling src before the locked loop memcpy's from it. */
767 15 SV *copy = sv_2mortal(newSVpvn(src, len));
768 15 args[i].str = SvPVX_const(copy);
769 15 args[i].len = len;
770 15 args[i].utf8 = utf8;
771 }
772 }
773 5 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
774 5 ▶ if (!queue_str_lock(h)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!queue_str_lock(h)) { 1 4 5
775 1 str_errno(h, QUEUE_FAILED);
776 1 XSRETURN_UV(0);
777 }
778 4 int r = 1;
779 14 ▶ for (uint32_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) { 12 2 14
780 12 ▶ r = queue_str_push_locked(h, args[i].str, LEN32(args[i].len), args[i].utf8);
Branch: 1 branch
BranchTrueFalseTotal
r = queue_str_push_locked(h, args[i].str, LEN32(args[i].len), args[i].utf8); 12 0 12
781 12 ▶ if (r == -2) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == -2) { 1 11 12
782 1 ▶ if (pushed) queue_wake_consumers_n(h->hdr, pushed);
Branch: 1 branch
BranchTrueFalseTotal
if (pushed) queue_wake_consumers_n(h->hdr, pushed); 1 0 1
783 1 queue_mutex_unlock(h->hdr);
784 1 croak(STR_TOO_BIG);
785 }
786 11 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 1 10 11
787 10 pushed++;
788 }
789 3 queue_mutex_unlock(h->hdr);
790 3 ▶ if (pushed) queue_wake_consumers_n(h->hdr, pushed);
Branch: 1 branch
BranchTrueFalseTotal
if (pushed) queue_wake_consumers_n(h->hdr, pushed); 3 0 3
791 3 ▶ if (r != 1) str_errno(h, r);
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) str_errno(h, r); 1 2 3
792 3 ▶ RETVAL = pushed;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pushed; 0 3 3
793 OUTPUT:
794 RETVAL
795  
796 void
797 pop_multi(self, count, ...)
798 SV *self
799 UV count
800 PREINIT:
801 12 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 12 0 12
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 12 12
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 12 12
802 UV n;
803 PPCODE:
804 12 ▶ uint64_t max_bytes = OPT_ARG(2) ? SvUV_nomg(ST(2)) : UINT64_MAX;
Branch: 4 branches
BranchTrueFalseTotal
uint64_t max_bytes = OPT_ARG(2) ? SvUV_nomg(ST(2)) : UINT64_MAX; 7 5 12
uint64_t max_bytes = OPT_ARG(2) ? SvUV_nomg(ST(2)) : UINT64_MAX; 0 7 7
uint64_t max_bytes = OPT_ARG(2) ? SvUV_nomg(ST(2)) : UINT64_MAX; 0 0 0
uint64_t max_bytes = OPT_ARG(2) ? SvUV_nomg(ST(2)) : UINT64_MAX; 6 1 7
805 12 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 12 12
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 12 12
806 12 StrItem *it = str_pop_batch(aTHX_ h, count, max_bytes, 0, 0, &n);
807 12 SP = str_push_items(aTHX_ SP, it, n);
808  
809 UV
810 size(self)
811 SV *self
812 PREINIT:
813 40009 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 40009 0 40009
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 40009 40009
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 40009 40009
814 CODE:
815 40009 RETVAL = (UV)queue_str_size(h);
816 OUTPUT:
817 RETVAL
818  
819 UV
820 capacity(self)
821 SV *self
822 PREINIT:
823 1 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 1 0 1
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1 1
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1 1
824 CODE:
825 1 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 0 1 1
826 OUTPUT:
827 RETVAL
828  
829 bool
830 is_empty(self)
831 SV *self
832 PREINIT:
833 8 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 8 0 8
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 8 8
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 8 8
834 CODE:
835 8 ▶ RETVAL = (queue_str_size(h) == 0);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (queue_str_size(h) == 0); 7 1 8
836 OUTPUT:
837 RETVAL
838  
839 bool
840 is_full(self)
841 SV *self
842 PREINIT:
843 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
844 CODE:
845 3 ▶ RETVAL = (queue_str_size(h) >= h->capacity);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (queue_str_size(h) >= h->capacity); 2 1 3
846 OUTPUT:
847 RETVAL
848  
849 bool
850 clear(self)
851 SV *self
852 PREINIT:
853 22 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 22 0 22
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 22 22
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 22 22
854 CODE:
855 22 RETVAL = str_ok(aTHX_ h, queue_str_clear(h));
856 OUTPUT:
857 RETVAL
858  
859 SV *
860 lock_timeout(self, ...)
861 SV *self
862 PREINIT:
863 4 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 4 0 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
864 CODE:
865 4 ▶ if (items > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (items > 1) { 3 1 4
866 3 ▶ double v = OPT_ARG(1) ? SvNV_nomg(ST(1)) : -1;
Branch: 4 branches
BranchTrueFalseTotal
double v = OPT_ARG(1) ? SvNV_nomg(ST(1)) : -1; 3 0 3
double v = OPT_ARG(1) ? SvNV_nomg(ST(1)) : -1; 0 3 3
double v = OPT_ARG(1) ? SvNV_nomg(ST(1)) : -1; 0 0 0
double v = OPT_ARG(1) ? SvNV_nomg(ST(1)) : -1; 2 1 3
867 3 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
868 3 ▶ h->lock_timeout = v >= 0 ? v : -1;
Branch: 1 branch
BranchTrueFalseTotal
h->lock_timeout = v >= 0 ? v : -1; 2 1 3
869 }
870 4 ▶ RETVAL = h->lock_timeout < 0 ? &PL_sv_undef : newSVnv(h->lock_timeout);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->lock_timeout < 0 ? &PL_sv_undef : newSVnv(h->lock_timeout); 2 2 4
871 OUTPUT:
872 RETVAL
873  
874 void
875 unlink(self_or_class, ...)
876 SV *self_or_class
877 CODE:
878 const char *path;
879 6 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Str")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Str")) { 5 1 6
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::Queue::Shared::Str")) { 5 0 5
880 5 QueueHandle *h = INT2PTR(QueueHandle*, SvIV(SvRV(self_or_class)));
881 5 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 5 5
882 5 path = h->path;
883 } else {
884 1 ▶ if (items < 2) croak("Usage: Data::Queue::Shared::Str->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::Queue::Shared::Str->unlink($path)"); 0 1 1
885 2 path = SvPV_nolen(ST(1));
886 }
887 6 ▶ if (!path) croak("cannot unlink anonymous or memfd queue");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd queue"); 0 6 6
888 6 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 6 6
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
889 0 croak("unlink(%s): %s", path, strerror(errno));
890  
891 SV *
892 path(self)
893 SV *self
894 PREINIT:
895 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 2 2
896 CODE:
897 2 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 1 1 2
898 OUTPUT:
899 RETVAL
900  
901 SV *
902 stats(self)
903 SV *self
904 PREINIT:
905 82 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 82 0 82
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 82 82
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 82 82
906 CODE:
907 82 HV *hv = newHV();
908 82 QueueHeader *hdr = h->hdr;
909 82 hv_store(hv, "size", 4, newSVuv((UV)queue_str_size(h)), 0);
910 82 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
911 82 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
912 82 hv_store(hv, "arena_cap", 9, newSVuv((UV)h->arena_cap), 0);
913 82 hv_store(hv, "arena_used", 10, newSVuv(__atomic_load_n(&hdr->arena_used, __ATOMIC_RELAXED)), 0);
914 82 hv_store(hv, "push_ok", 7, newSVuv((UV)__atomic_load_n(&hdr->stat_push_ok, __ATOMIC_RELAXED)), 0);
915 82 hv_store(hv, "pop_ok", 6, newSVuv((UV)__atomic_load_n(&hdr->stat_pop_ok, __ATOMIC_RELAXED)), 0);
916 82 hv_store(hv, "push_full", 9, newSVuv((UV)__atomic_load_n(&hdr->stat_push_full, __ATOMIC_RELAXED)), 0);
917 82 hv_store(hv, "pop_empty", 9, newSVuv((UV)__atomic_load_n(&hdr->stat_pop_empty, __ATOMIC_RELAXED)), 0);
918 82 hv_store(hv, "recoveries", 10, newSVuv((UV)__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
919 82 hv_store(hv, "push_waiters", 12, newSVuv((UV)__atomic_load_n(&hdr->push_waiters, __ATOMIC_RELAXED)), 0);
920 82 hv_store(hv, "pop_waiters", 11, newSVuv((UV)__atomic_load_n(&hdr->pop_waiters, __ATOMIC_RELAXED)), 0);
921 82 hv_store(hv, "lock_waits", 10, newSVuv((UV)__atomic_load_n(&hdr->stat_lock_waits, __ATOMIC_RELAXED)), 0);
922 82 hv_store(hv, "lock_wait_time", 14, newSVnv(__atomic_load_n(&hdr->stat_lock_wait_ns, __ATOMIC_RELAXED) / 1e9), 0);
923 82 hv_store(hv, "lock_wait_max", 13, newSVnv(__atomic_load_n(&hdr->stat_lock_wait_max_ns, __ATOMIC_RELAXED) / 1e9), 0);
924 82 hv_store(hv, "lock_timeouts", 13, newSVuv((UV)__atomic_load_n(&hdr->stat_lock_timeouts, __ATOMIC_RELAXED)), 0);
925 82 hv_store(hv, "last_recovery", 13, newSVuv((UV)__atomic_load_n(&hdr->stat_last_recovery, __ATOMIC_RELAXED)), 0);
926 82 RETVAL = newRV_noinc((SV *)hv);
927 OUTPUT:
928 RETVAL
929  
930 SV *
931 peek(self)
932 SV *self
933 PREINIT:
934 9 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 9 0 9
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 9 9
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 9 9
935 9 const char *str = NULL;
936 9 uint32_t len = 0;
937 9 bool utf8 = false;
938 CODE:
939 9 int r = queue_str_peek(h, &str, &len, &utf8);
940 9 RETVAL = str_sv(aTHX_ h, r, str, len, utf8);
941 OUTPUT:
942 RETVAL
943  
944 bool
945 push_front(self, value)
946 SV *self
947 SV *value
948 PREINIT:
949 10032 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 10032 0 10032
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10032 10032
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10032 10032
950 STRLEN len;
951 CODE:
952 10032 const char *str = SvPV(value, len);
953 10032 bool utf8 = SvUTF8(value) ? true : false;
954 10032 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10032 10032
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10032 10032
955 10032 ▶ int r = queue_str_push_front(h, str, LEN32(len), utf8);
Branch: 1 branch
BranchTrueFalseTotal
int r = queue_str_push_front(h, str, LEN32(len), utf8); 10032 0 10032
956 10032 RETVAL = str_ok(aTHX_ h, r);
957 OUTPUT:
958 RETVAL
959  
960 bool
961 push_front_wait(self, value, ...)
962 SV *self
963 SV *value
964 PREINIT:
965 4 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 4 0 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
966 4 double timeout = -1;
967 STRLEN len;
968 CODE:
969 4 ▶ if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 3 1 4
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 3 3
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 0 0
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 3 0 3
970 4 const char *str = SvPV(value, len);
971 4 bool utf8 = SvUTF8(value) ? true : false;
972 4 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
973 4 ▶ int r = queue_str_push_front_wait(h, str, LEN32(len), utf8, timeout);
Branch: 1 branch
BranchTrueFalseTotal
int r = queue_str_push_front_wait(h, str, LEN32(len), utf8, timeout); 4 0 4
974 4 RETVAL = str_ok(aTHX_ h, r);
975 OUTPUT:
976 RETVAL
977  
978 void
979 drain(self, ...)
980 SV *self
981 PREINIT:
982 15 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 15 0 15
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 15 15
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 15 15
983 UV n;
984 PPCODE:
985 15 ▶ UV max_count = OPT_ARG(1) ? SvUV_nomg(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
UV max_count = OPT_ARG(1) ? SvUV_nomg(ST(1)) : UINT32_MAX; 3 12 15
UV max_count = OPT_ARG(1) ? SvUV_nomg(ST(1)) : UINT32_MAX; 0 3 3
UV max_count = OPT_ARG(1) ? SvUV_nomg(ST(1)) : UINT32_MAX; 0 0 0
UV max_count = OPT_ARG(1) ? SvUV_nomg(ST(1)) : UINT32_MAX; 3 0 3
986 15 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 15 15
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 15 15
987 15 StrItem *it = str_pop_batch(aTHX_ h, max_count, UINT64_MAX, 0, 0, &n);
988 15 SP = str_push_items(aTHX_ SP, it, n);
989  
990 void
991 pop_wait_multi(self, count, ...)
992 SV *self
993 UV count
994 PREINIT:
995 14 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 14 0 14
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 14 14
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 14 14
996 14 double timeout = -1;
997 14 const char *str = NULL;
998 14 uint32_t len = 0;
999 14 bool utf8 = false;
1000 UV n;
1001 PPCODE:
1002 14 ▶ if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 14 0 14
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 14 14
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 0 0 0
if (OPT_ARG(2)) timeout = SvNV_nomg(ST(2)); 14 0 14
1003 14 ▶ uint64_t max_bytes = OPT_ARG(3) ? SvUV_nomg(ST(3)) : UINT64_MAX;
Branch: 4 branches
BranchTrueFalseTotal
uint64_t max_bytes = OPT_ARG(3) ? SvUV_nomg(ST(3)) : UINT64_MAX; 5 9 14
uint64_t max_bytes = OPT_ARG(3) ? SvUV_nomg(ST(3)) : UINT64_MAX; 0 5 5
uint64_t max_bytes = OPT_ARG(3) ? SvUV_nomg(ST(3)) : UINT64_MAX; 0 0 0
uint64_t max_bytes = OPT_ARG(3) ? SvUV_nomg(ST(3)) : UINT64_MAX; 4 1 5
1004 14 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 14 14
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 14 14
1005 14 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 1 13 14
1006 13 int r = queue_str_pop_wait(h, &str, &len, &utf8, timeout);
1007 13 SV *first = str_sv(aTHX_ h, r, str, len, utf8);
1008 13 ▶ if (r != 1) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) XSRETURN(0); 2 11 13
1009 11 ▶ XPUSHs(sv_2mortal(first));
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(sv_2mortal(first)); 0 11 11
1010 11 StrItem *it = str_pop_batch(aTHX_ h, count - 1, max_bytes, len, 1, &n);
1011 11 SP = str_push_items(aTHX_ SP, it, n);
1012  
1013 UV
1014 push_wait_multi(self, timeout, ...)
1015 SV *self
1016 double timeout
1017 PREINIT:
1018 5 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 5 0 5
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 5 5
1019 CODE:
1020 5 uint32_t nvalues = items - 2;
1021 struct timespec dl, rem;
1022 5 int has_dl = (timeout > 0);
1023 5 ▶ if (has_dl) queue_make_deadline(timeout, &dl);
Branch: 1 branch
BranchTrueFalseTotal
if (has_dl) queue_make_deadline(timeout, &dl); 4 1 5
1024 5 RETVAL = 0;
1025 1010 ▶ for (uint32_t i = 0; i < nvalues; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < nvalues; i++) { 1007 3 1010
1026 1007 double t = timeout;
1027 1007 ▶ if (has_dl) {
Branch: 1 branch
BranchTrueFalseTotal
if (has_dl) { 1004 3 1007
1028 2008 t = queue_remaining_time(&dl, &rem)
1029 1004 ▶ ? (double)rem.tv_sec + (double)rem.tv_nsec * 1e-9 : 0;
Branch: 1 branch
BranchTrueFalseTotal
? (double)rem.tv_sec + (double)rem.tv_nsec * 1e-9 : 0; 5 999 1004
1030 }
1031 1007 SV *sv = ST(i + 2);
1032 STRLEN len;
1033 1007 const char *str = SvPV(sv, len);
1034 1007 bool utf8 = SvUTF8(sv) ? true : false;
1035 1007 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1007 1007
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1007 1007
1036 1007 ▶ if (!str_ok(aTHX_ h, queue_str_push_wait(h, str, LEN32(len), utf8, t))) break;
Branch: 2 branches
BranchTrueFalseTotal
if (!str_ok(aTHX_ h, queue_str_push_wait(h, str, LEN32(len), utf8, t))) break; 1007 0 1007
if (!str_ok(aTHX_ h, queue_str_push_wait(h, str, LEN32(len), utf8, t))) break; 2 1005 1007
1037 1005 RETVAL++;
1038 }
1039 OUTPUT:
1040 RETVAL
1041  
1042 SV *
1043 pop_back(self)
1044 SV *self
1045 PREINIT:
1046 10183 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 10183 0 10183
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10183 10183
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 10183 10183
1047 10183 const char *str = NULL;
1048 10183 uint32_t len = 0;
1049 10183 bool utf8 = false;
1050 CODE:
1051 10183 int r = queue_str_pop_back(h, &str, &len, &utf8);
1052 10183 RETVAL = str_sv(aTHX_ h, r, str, len, utf8);
1053 OUTPUT:
1054 RETVAL
1055  
1056 SV *
1057 pop_back_wait(self, ...)
1058 SV *self
1059 PREINIT:
1060 6 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 6 0 6
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 6 6
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 6 6
1061 6 double timeout = -1;
1062 6 const char *str = NULL;
1063 6 uint32_t len = 0;
1064 6 bool utf8 = false;
1065 CODE:
1066 6 ▶ if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 6 0 6
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 6 6
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 0 0 0
if (OPT_ARG(1)) timeout = SvNV_nomg(ST(1)); 6 0 6
1067 6 ▶ REEXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 6 6
REEXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 6 6
1068 6 int r = queue_str_pop_back_wait(h, &str, &len, &utf8, timeout);
1069 6 RETVAL = str_sv(aTHX_ h, r, str, len, utf8);
1070 OUTPUT:
1071 RETVAL
1072  
1073 void
1074 sync(self)
1075 SV *self
1076 PREINIT:
1077 2 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 2 2
1078 CODE:
1079 2 ▶ if (queue_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (queue_sync(h) != 0) 0 2 2
1080 0 croak("msync: %s", strerror(errno));
1081  
1082 IV
1083 eventfd(self)
1084 SV *self
1085 PREINIT:
1086 4 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 4 0 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 4 4
1087 CODE:
1088 4 RETVAL = queue_eventfd_create(h);
1089 4 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 4 4
1090 OUTPUT:
1091 RETVAL
1092  
1093 void
1094 eventfd_set(self, fd)
1095 SV *self
1096 int fd
1097 PREINIT:
1098 1 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 1 0 1
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1 1
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 1 1
1099 CODE:
1100 1 queue_eventfd_set(h, fd);
1101  
1102 IV
1103 fileno(self)
1104 SV *self
1105 PREINIT:
1106 0 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 0 0
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 0 0
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 0 0
1107 CODE:
1108 0 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 0 0 0
1109 OUTPUT:
1110 RETVAL
1111  
1112 SV *
1113 eventfd_consume(self)
1114 SV *self
1115 PREINIT:
1116 8 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 8 0 8
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 8 8
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 8 8
1117 CODE:
1118 8 int64_t v = queue_eventfd_consume(h);
1119 8 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 7 1 8
1120 OUTPUT:
1121 RETVAL
1122  
1123 void
1124 notify(self)
1125 SV *self
1126 PREINIT:
1127 3 ▶ EXTRACT_HANDLE("Data::Queue::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 3 0 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
EXTRACT_HANDLE("Data::Queue::Shared::Str", self); 0 3 3
1128 CODE:
1129 3 queue_notify(h);
1130  
1131 MODULE = Data::Queue::Shared PACKAGE = Data::Queue::Shared::Int32
1132  
1133 PROTOTYPES: DISABLE
1134  
1135 INCLUDE_COMMAND: $^X -e "use strict; my \$t = do{local \$/; open my \$f,'<','Shared.xs' or die; <\$f>}; my (\$int_section) = \$t =~ /^(MODULE.*?PACKAGE = Data::Queue::Shared::Int\n.*?)^MODULE/ms; \$int_section =~ s/Data::Queue::Shared::Int(?!\\d)/Data::Queue::Shared::Int32/g; \$int_section =~ s/queue_int_/queue_int32_/g; \$int_section =~ s/QUEUE_MODE_INT(?!\\d)/QUEUE_MODE_INT32/g; \$int_section =~ s/int64_t/int32_t/g; \$int_section =~ s/^MODULE.*\\n//m; \$int_section =~ s/^BOOT:\\n(?:.*\\n)*?\\/\\* XSMARKER.*\\n//m; print \$int_section"
1136  
1137 MODULE = Data::Queue::Shared PACKAGE = Data::Queue::Shared::Int16
1138  
1139 PROTOTYPES: DISABLE
1140  
1141 INCLUDE_COMMAND: $^X -e "use strict; my \$t = do{local \$/; open my \$f,'<','Shared.xs' or die; <\$f>}; my (\$int_section) = \$t =~ /^(MODULE.*?PACKAGE = Data::Queue::Shared::Int\n.*?)^MODULE/ms; \$int_section =~ s/Data::Queue::Shared::Int(?!\\d)/Data::Queue::Shared::Int16/g; \$int_section =~ s/queue_int_/queue_int16_/g; \$int_section =~ s/QUEUE_MODE_INT(?!\\d)/QUEUE_MODE_INT16/g; \$int_section =~ s/int64_t/int16_t/g; \$int_section =~ s/^MODULE.*\\n//m; \$int_section =~ s/^BOOT:\\n(?:.*\\n)*?\\/\\* XSMARKER.*\\n//m; print \$int_section"
« queue.h ↑ Summary blib/lib/Data/Queue/Shared/Int.pm »