Shared.xs

filter: Statementstmt 89.7% 766 / 854 Branchbran 45.8% 836 / 1822 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 59.8% 1602 / 2676 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Data/PubSub/Shared.pm ↑ Summary pubsub.h »
1 #define PERL_NO_GET_CONTEXT
2 #include "EXTERN.h"
3 #include "perl.h"
4 #include "XSUB.h"
5  
6 #include "ppport.h"
7  
8 12 static int pubsub_wait_interrupted(void) { dTHX; return PL_sig_pending != 0; }
9 #define PUBSUB_WAIT_INTERRUPTED() pubsub_wait_interrupted()
10 #include "pubsub.h"
11  
12 #include "XSParseKeyword.h"
13  
14 /* Narrow a Perl string length to the uint32 wire width WITHOUT silent truncation:
15 * a length that doesn't fit maps to UINT32_MAX so the downstream < 2 GiB size
16 * check croaks, instead of the value wrapping to a small, wrongly-accepted length. */
17 #define LEN32(len) ((len) > (STRLEN)0xFFFFFFFFU ? 0xFFFFFFFFU : (uint32_t)(len))
18  
19 16 static int build_kw_1arg(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata) {
20 (void)nargs;
21 16 const char *func = (const char *)hookdata;
22 16 OP *q_op = args[0]->op;
23 16 OP *cvref = newCVREF(0, newGVOP(OP_GV, 0, gv_fetchpv(func, GV_ADD, SVt_PVCV)));
24 16 *out = op_convert_list(OP_ENTERSUB, OPf_STACKED,
25 op_append_elem(OP_LIST, q_op, cvref));
26 16 return KEYWORD_PLUGIN_EXPR;
27 }
28  
29 8 static int build_kw_2arg(pTHX_ OP **out, XSParseKeywordPiece *args[], size_t nargs, void *hookdata) {
30 (void)nargs;
31 8 const char *func = (const char *)hookdata;
32 8 OP *q_op = args[0]->op;
33 8 OP *val_op = args[1]->op;
34 8 OP *cvref = newCVREF(0, newGVOP(OP_GV, 0, gv_fetchpv(func, GV_ADD, SVt_PVCV)));
35 8 OP *arglist = op_append_elem(OP_LIST, q_op, val_op);
36 8 arglist = op_append_elem(OP_LIST, arglist, cvref);
37 8 *out = op_convert_list(OP_ENTERSUB, OPf_STACKED, arglist);
38 8 return KEYWORD_PLUGIN_EXPR;
39 }
40  
41 static const struct XSParseKeywordPieceType pieces_1expr[] = {
42 XPK_TERMEXPR, {0}
43 };
44  
45 static const struct XSParseKeywordPieceType pieces_2expr[] = {
46 XPK_TERMEXPR, XPK_COMMA, XPK_TERMEXPR, {0}
47 };
48  
49 #define DEFINE_PS_KW(variant, PKG, kw, nargs, builder) \
50 static const struct XSParseKeywordHooks hooks_ps_##variant##_##kw = { \
51 .flags = XPK_FLAG_EXPR, \
52 .permit_hintkey = "Data::PubSub::Shared::" PKG "/ps_" #variant "_" #kw, \
53 .pieces = pieces_##nargs##expr, \
54 .build = builder, \
55 };
56  
57 /* Publisher keywords */
58 DEFINE_PS_KW(int, "Int", publish, 2, build_kw_2arg)
59  
60 /* Subscriber keywords */
61 DEFINE_PS_KW(int, "Int", poll, 1, build_kw_1arg)
62 DEFINE_PS_KW(int, "Int", lag, 1, build_kw_1arg)
63  
64 /* Str publisher keywords */
65 DEFINE_PS_KW(str, "Str", publish, 2, build_kw_2arg)
66  
67 /* Int32 keywords */
68 DEFINE_PS_KW(int32, "Int32", publish, 2, build_kw_2arg)
69 DEFINE_PS_KW(int32, "Int32", poll, 1, build_kw_1arg)
70 DEFINE_PS_KW(int32, "Int32", lag, 1, build_kw_1arg)
71  
72 /* Int16 keywords */
73 DEFINE_PS_KW(int16, "Int16", publish, 2, build_kw_2arg)
74 DEFINE_PS_KW(int16, "Int16", poll, 1, build_kw_1arg)
75 DEFINE_PS_KW(int16, "Int16", lag, 1, build_kw_1arg)
76  
77 /* Str subscriber keywords */
78 DEFINE_PS_KW(str, "Str", poll, 1, build_kw_1arg)
79 DEFINE_PS_KW(str, "Str", lag, 1, build_kw_1arg)
80  
81 #define REGISTER_PS_KW(variant, kw, func_name) \
82 register_xs_parse_keyword("ps_" #variant "_" #kw, \
83 &hooks_ps_##variant##_##kw, (void*)func_name)
84  
85 #define EXTRACT_HANDLE(classname, sv) \
86 if (!sv_isobject(sv) || !sv_derived_from(sv, classname)) \
87 croak("Expected a %s object", classname); \
88 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(sv))); \
89 if (!h) croak("Attempted to use a destroyed %s object", classname); \
90 PubSubHandle *h0 = h; PERL_UNUSED_VAR(h0); \
91 sv_2mortal(SvREFCNT_inc(SvRV(sv)))
92  
93 /* Re-read the handle after a call that can run Perl code (tied/overloaded
94 * argument magic, tied-array fetches). That code may call $obj->DESTROY
95 * explicitly, which frees the handle and zeroes the IV; EXTRACT_HANDLE's
96 * mortal pins the referent only against refcount-driven destruction, not an
97 * explicit DESTROY, so the local `h` would dangle. The same Perl can also
98 * REPLACE the invocant ($obj = 42 mutates ST(0), because Perl passes
99 * aliases), hence the SvROK re-check before SvRV. Used only where magic
100 * can actually intervene between EXTRACT_HANDLE and the first use of h. */
101 #define REEXTRACT_HANDLE(classname, sv) \
102 if (!SvROK(sv)) \
103 croak("%s object was replaced during the call", classname); \
104 h = INT2PTR(PubSubHandle*, SvIV(SvRV(sv))); \
105 if (h != h0) croak("%s object replaced or destroyed during the call", classname)
106  
107 #define MAKE_OBJ(class, ptr) \
108 SV *ref = newRV_noinc(newSViv(PTR2IV(ptr))); \
109 sv_bless(ref, gv_stashpv(class, GV_ADD)); \
110 RETVAL = ref
111  
112 #define EXTRACT_SUB(classname, sv) \
113 if (!sv_isobject(sv) || !sv_derived_from(sv, classname)) \
114 croak("Expected a %s object", classname); \
115 PubSubSub *sub = INT2PTR(PubSubSub*, SvIV(SvRV(sv))); \
116 if (!sub) croak("Attempted to use a destroyed %s object", classname); \
117 PubSubSub *sub0 = sub; PERL_UNUSED_VAR(sub0); \
118 sv_2mortal(SvREFCNT_inc(SvRV(sv))) /* pin the invocant across the method (reentrant-DESTROY UAF guard) */
119  
120 /* Re-read the subscriber after a call that can run Perl code (tied/overloaded
121 * argument magic, tied-array fetches). That code may call $obj->DESTROY
122 * explicitly, which frees the subscriber and zeroes the IV; EXTRACT_SUB's
123 * mortal pins the referent only against refcount-driven destruction, not an
124 * explicit DESTROY, so the local `sub` would dangle. The same Perl can also
125 * REPLACE the invocant ($obj = 42 mutates ST(0), because Perl passes
126 * aliases), hence the SvROK re-check before SvRV. Used only where magic
127 * can actually intervene between EXTRACT_SUB and the first use of sub. */
128 #define REEXTRACT_SUB(classname, sv) \
129 if (!SvROK(sv)) \
130 croak("%s object was replaced during the call", classname); \
131 sub = INT2PTR(PubSubSub*, SvIV(SvRV(sv))); \
132 if (sub != sub0) croak("%s object replaced or destroyed during the call", classname)
133  
134 403 static void pubsub_perl_mutex_lock(pTHX_ SV *self, PubSubHandle *h) {
135 403 PubSubHandle *h0 = h;
136 struct timespec deadline;
137 403 pubsub_make_deadline(PUBSUB_LOCK_TIMEOUT_SEC, &deadline);
138 403 ▶ while (pubsub_mutex_lock_until(h->hdr, &deadline, 1) < 0) {
Branch: 1 branch
BranchTrueFalseTotal
while (pubsub_mutex_lock_until(h->hdr, &deadline, 1) < 0) { 0 403 403
139 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
140 0 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared", self); 0 0 0
REEXTRACT_HANDLE("Data::PubSub::Shared", self); 0 0 0
141 }
142 403 }
143  
144 396 static int pubsub_perl_str_publish(pTHX_ SV *self, PubSubHandle *h,
145 const char *str, uint32_t len, bool utf8) {
146 396 ▶ if (len > h->msg_size) return -1;
Branch: 1 branch
BranchTrueFalseTotal
if (len > h->msg_size) return -1; 2 394 396
147 394 SV *copy = sv_2mortal(newSVpvn(str, len));
148 394 pubsub_perl_mutex_lock(aTHX_ self, h);
149 394 int result = pubsub_str_publish_locked(h, SvPVX_const(copy), len, utf8);
150 394 pubsub_mutex_unlock(h->hdr);
151 394 ▶ if (result == 1) pubsub_wake_subscribers_fenced(h->hdr);
Branch: 1 branch
BranchTrueFalseTotal
if (result == 1) pubsub_wake_subscribers_fenced(h->hdr); 394 0 394
152 394 return result;
153 }
154  
155 11 static int pubsub_perl_int_poll_wait(pTHX_ SV *self, PubSubSub *sub,
156 int64_t *value, double timeout) {
157 11 PubSubSub *sub0 = sub;
158 11 SV *owner = (SV *)sub->userdata;
159 11 PubSubHandle *h = INT2PTR(PubSubHandle *, SvIV(SvRV(owner)));
160 11 PubSubHandle *h0 = h;
161 struct timespec deadline, remaining;
162 11 ▶ if (timeout > 0) pubsub_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) pubsub_make_deadline(timeout, &deadline); 11 0 11
163 11 double seconds = timeout;
164 0 for (;;) {
165 11 int result = pubsub_int_poll_wait(sub, value, seconds);
166 11 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 11 0 11
167 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
168 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 0 0
169 0 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int", owner);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int", owner); 0 0 0
REEXTRACT_HANDLE("Data::PubSub::Shared::Int", owner); 0 0 0
170 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
171 0 ▶ if (!pubsub_remaining_time(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_remaining_time(&deadline, &remaining)) return 0; 0 0 0
172 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
173 }
174 }
175 }
176  
177 2 static int pubsub_perl_int32_poll_wait(pTHX_ SV *self, PubSubSub *sub,
178 int32_t *value, double timeout) {
179 2 PubSubSub *sub0 = sub;
180 2 SV *owner = (SV *)sub->userdata;
181 2 PubSubHandle *h = INT2PTR(PubSubHandle *, SvIV(SvRV(owner)));
182 2 PubSubHandle *h0 = h;
183 struct timespec deadline, remaining;
184 2 ▶ if (timeout > 0) pubsub_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) pubsub_make_deadline(timeout, &deadline); 2 0 2
185 2 double seconds = timeout;
186 0 for (;;) {
187 2 int result = pubsub_int32_poll_wait(sub, value, seconds);
188 2 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 2 0 2
189 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
190 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
191 0 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", owner);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", owner); 0 0 0
REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", owner); 0 0 0
192 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
193 0 ▶ if (!pubsub_remaining_time(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_remaining_time(&deadline, &remaining)) return 0; 0 0 0
194 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
195 }
196 }
197 }
198  
199 2 static int pubsub_perl_int16_poll_wait(pTHX_ SV *self, PubSubSub *sub,
200 int16_t *value, double timeout) {
201 2 PubSubSub *sub0 = sub;
202 2 SV *owner = (SV *)sub->userdata;
203 2 PubSubHandle *h = INT2PTR(PubSubHandle *, SvIV(SvRV(owner)));
204 2 PubSubHandle *h0 = h;
205 struct timespec deadline, remaining;
206 2 ▶ if (timeout > 0) pubsub_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) pubsub_make_deadline(timeout, &deadline); 2 0 2
207 2 double seconds = timeout;
208 0 for (;;) {
209 2 int result = pubsub_int16_poll_wait(sub, value, seconds);
210 2 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 2 0 2
211 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
212 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
213 0 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", owner);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", owner); 0 0 0
REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", owner); 0 0 0
214 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
215 0 ▶ if (!pubsub_remaining_time(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_remaining_time(&deadline, &remaining)) return 0; 0 0 0
216 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
217 }
218 }
219 }
220  
221 55 static int pubsub_perl_str_poll_wait(pTHX_ SV *self, PubSubSub *sub,
222 const char **str, uint32_t *len, bool *utf8, double timeout) {
223 55 PubSubSub *sub0 = sub;
224 55 SV *owner = (SV *)sub->userdata;
225 55 PubSubHandle *h = INT2PTR(PubSubHandle *, SvIV(SvRV(owner)));
226 55 PubSubHandle *h0 = h;
227 struct timespec deadline, remaining;
228 55 ▶ if (timeout > 0) pubsub_make_deadline(timeout, &deadline);
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) pubsub_make_deadline(timeout, &deadline); 55 0 55
229 55 double seconds = timeout;
230 0 for (;;) {
231 55 int result = pubsub_str_poll_wait(sub, str, len, utf8, seconds);
232 55 ▶ if (result >= 0) return result;
Branch: 1 branch
BranchTrueFalseTotal
if (result >= 0) return result; 55 0 55
233 0 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 0 0
234 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 0 0
235 0 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Str", owner);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", owner); 0 0 0
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", owner); 0 0 0
236 0 ▶ if (timeout > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (timeout > 0) { 0 0 0
237 0 ▶ if (!pubsub_remaining_time(&deadline, &remaining)) return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_remaining_time(&deadline, &remaining)) return 0; 0 0 0
238 0 seconds = (double)remaining.tv_sec + (double)remaining.tv_nsec / 1e9;
239 }
240 }
241 }
242  
243 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int
244  
245 PROTOTYPES: DISABLE
246  
247 BOOT:
248 28 boot_xs_parse_keyword(0.40);
249 28 REGISTER_PS_KW(int, publish, "Data::PubSub::Shared::Int::publish");
250 28 REGISTER_PS_KW(int, poll, "Data::PubSub::Shared::Int::Sub::poll");
251 28 REGISTER_PS_KW(int, lag, "Data::PubSub::Shared::Int::Sub::lag");
252 28 REGISTER_PS_KW(int32, publish, "Data::PubSub::Shared::Int32::publish");
253 28 REGISTER_PS_KW(int32, poll, "Data::PubSub::Shared::Int32::Sub::poll");
254 28 REGISTER_PS_KW(int32, lag, "Data::PubSub::Shared::Int32::Sub::lag");
255 28 REGISTER_PS_KW(int16, publish, "Data::PubSub::Shared::Int16::publish");
256 28 REGISTER_PS_KW(int16, poll, "Data::PubSub::Shared::Int16::Sub::poll");
257 28 REGISTER_PS_KW(int16, lag, "Data::PubSub::Shared::Int16::Sub::lag");
258 28 REGISTER_PS_KW(str, publish, "Data::PubSub::Shared::Str::publish");
259 28 REGISTER_PS_KW(str, poll, "Data::PubSub::Shared::Str::Sub::poll");
260 28 REGISTER_PS_KW(str, lag, "Data::PubSub::Shared::Str::Sub::lag");
261  
262 SV *
263 new(class, path, capacity, ...)
264 const char *class
265 SV *path
266 UV capacity
267 PREINIT:
268 char errbuf[PUBSUB_ERR_BUFLEN];
269 CODE:
270 74 ▶ mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 74 74
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
271 114 ▶ 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 74 74
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; 40 34 74
272 74 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 74 74
273 74 PubSubHandle *h = pubsub_create(p, (uint32_t)capacity, PUBSUB_MODE_INT, 0, fmode, errbuf);
274 74 ▶ if (!h) croak("Data::PubSub::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 4 70 74
if (!h) croak("Data::PubSub::Shared::Int->new: %s", errbuf[0] ? errbuf : "out of memory"); 4 0 4
275 70 MAKE_OBJ(class, h);
276 OUTPUT:
277 RETVAL
278  
279 SV *
280 new_memfd(class, name, capacity)
281 const char *class
282 const char *name
283 UV capacity
284 PREINIT:
285 char errbuf[PUBSUB_ERR_BUFLEN];
286 CODE:
287 2 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 2 2
288 2 PubSubHandle *h = pubsub_create_memfd(name, (uint32_t)capacity, PUBSUB_MODE_INT, 0, errbuf);
289 2 ▶ if (!h) croak("Data::PubSub::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
290 2 MAKE_OBJ(class, h);
291 OUTPUT:
292 RETVAL
293  
294 SV *
295 new_from_fd(class, fd)
296 const char *class
297 int fd
298 PREINIT:
299 char errbuf[PUBSUB_ERR_BUFLEN];
300 CODE:
301 2 PubSubHandle *h = pubsub_open_fd(fd, PUBSUB_MODE_INT, errbuf);
302 2 ▶ if (!h) croak("Data::PubSub::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
303 2 MAKE_OBJ(class, h);
304 OUTPUT:
305 RETVAL
306  
307 IV
308 memfd(self)
309 SV *self
310 PREINIT:
311 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
312 CODE:
313 2 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 0 2 2
314 OUTPUT:
315 RETVAL
316  
317 void
318 DESTROY(self)
319 SV *self
320 CODE:
321 74 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int")) return; 74 0 74
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int")) return; 0 74 74
322 74 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self)));
323 74 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 74 74
324 74 sv_setiv(SvRV(self), 0);
325 74 pubsub_destroy(h);
326  
327 bool
328 publish(self, value)
329 SV *self
330 IV value
331 PREINIT:
332 470 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 470 0 470
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 470 470
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 470 470
333 CODE:
334 470 ▶ RETVAL = pubsub_int_publish(h, (int64_t)value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pubsub_int_publish(h, (int64_t)value); 470 0 470
335 OUTPUT:
336 RETVAL
337  
338 #ifdef PUBSUB_TEST_HOOKS
339  
340 void
341 _publish_at(self, pos, value)
342 SV *self
343 UV pos
344 IV value
345 PREINIT:
346 EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
347 CODE:
348 /* test-only: commit at an explicit ring position WITHOUT advancing
349 write_pos, so a regression test can deterministically recreate the
350 lapped-publisher race. Compiled only with -DPUBSUB_TEST_HOOKS. */
351 pubsub_int_commit_at(h, (uint64_t)pos, (int64_t)value);
352  
353 UV
354 _slot_seq(self, pos)
355 SV *self
356 UV pos
357 PREINIT:
358 EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
359 CODE:
360 /* test-only: raw slot sequence at a ring position (revert detection). */
361 RETVAL = (UV)((PubSubIntSlot *)h->slots)[pos & h->cap_mask].sequence;
362 OUTPUT:
363 RETVAL
364  
365 #endif
366  
367 UV
368 publish_multi(self, ...)
369 SV *self
370 PREINIT:
371 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
372 CODE:
373 6 uint32_t count = items - 1;
374 6 ▶ if (count == 0) { RETVAL = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) { RETVAL = 0; } 1 5 6
375 else {
376 5 ▶ if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count); 0 5 5
377 5 int64_t *vals = (int64_t *)alloca(count * sizeof(int64_t));
378 218 ▶ for (uint32_t i = 0; i < count; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) 213 5 218
379 213 vals[i] = (int64_t)SvIV(ST(i + 1));
380 5 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 5 5
REEXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 5 5
381 5 RETVAL = pubsub_int_publish_multi(h, vals, count);
382 }
383 OUTPUT:
384 RETVAL
385  
386 void
387 publish_notify(self, value)
388 SV *self
389 IV value
390 PREINIT:
391 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
392 CODE:
393 2 pubsub_int_publish(h, (int64_t)value);
394 2 pubsub_notify(h);
395  
396 SV *
397 subscribe(self)
398 SV *self
399 PREINIT:
400 22 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 22 0 22
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 22 22
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 22 22
401 CODE:
402 22 PubSubSub *sub = pubsub_subscribe(h, 0);
403 22 ▶ if (!sub) croak("subscribe: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe: out of memory"); 0 22 22
404 22 sub->userdata = (void *)newSVsv(self);
405 22 MAKE_OBJ("Data::PubSub::Shared::Int::Sub", sub);
406 OUTPUT:
407 RETVAL
408  
409 SV *
410 subscribe_all(self)
411 SV *self
412 PREINIT:
413 28 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 28 0 28
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 28 28
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 28 28
414 CODE:
415 28 PubSubSub *sub = pubsub_subscribe(h, 1);
416 28 ▶ if (!sub) croak("subscribe_all: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe_all: out of memory"); 0 28 28
417 28 sub->userdata = (void *)newSVsv(self);
418 28 MAKE_OBJ("Data::PubSub::Shared::Int::Sub", sub);
419 OUTPUT:
420 RETVAL
421  
422 UV
423 capacity(self)
424 SV *self
425 PREINIT:
426 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 1 1
427 CODE:
428 1 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 0 1 1
429 OUTPUT:
430 RETVAL
431  
432 UV
433 write_pos(self)
434 SV *self
435 PREINIT:
436 14 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 14 0 14
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 14 14
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 14 14
437 CODE:
438 14 ▶ RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED); 0 14 14
439 OUTPUT:
440 RETVAL
441  
442 SV *
443 path(self)
444 SV *self
445 PREINIT:
446 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 2 2
447 CODE:
448 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
449 OUTPUT:
450 RETVAL
451  
452 SV *
453 stats(self)
454 SV *self
455 PREINIT:
456 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 5 5
457 CODE:
458 5 HV *hv = newHV();
459 5 PubSubHeader *hdr = h->hdr;
460 5 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
461 5 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
462 5 hv_store(hv, "write_pos", 9,
463 newSVuv((UV)__atomic_load_n(&hdr->write_pos, __ATOMIC_RELAXED)), 0);
464 5 hv_store(hv, "publish_ok", 10,
465 newSVuv((UV)__atomic_load_n(&hdr->stat_publish_ok, __ATOMIC_RELAXED)), 0);
466 5 hv_store(hv, "recoveries", 10,
467 newSVuv(__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
468 5 hv_store(hv, "sub_waiters", 11,
469 newSVuv(__atomic_load_n(&hdr->sub_waiters, __ATOMIC_RELAXED)), 0);
470 5 RETVAL = newRV_noinc((SV *)hv);
471 OUTPUT:
472 RETVAL
473  
474 void
475 clear(self)
476 SV *self
477 PREINIT:
478 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 4 4
479 CODE:
480 4 pubsub_clear(h);
481  
482 void
483 sync(self)
484 SV *self
485 PREINIT:
486 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 4 4
487 CODE:
488 4 ▶ if (pubsub_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_sync(h) != 0) 0 4 4
489 0 croak("msync: %s", strerror(errno));
490  
491 void
492 unlink(self_or_class, ...)
493 SV *self_or_class
494 CODE:
495 const char *path;
496 1 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int")) { 1 0 1
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int")) { 1 0 1
497 1 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self_or_class)));
498 1 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 1 1
499 1 path = h->path;
500 } else {
501 0 ▶ if (items < 2) croak("Usage: Data::PubSub::Shared::Int->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::PubSub::Shared::Int->unlink($path)"); 0 0 0
502 0 path = SvPV_nolen(ST(1));
503 }
504 1 ▶ if (!path) croak("cannot unlink anonymous or memfd pubsub");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd pubsub"); 0 1 1
505 1 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 1 1
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
506 0 croak("unlink(%s): %s", path, strerror(errno));
507  
508 IV
509 eventfd(self)
510 SV *self
511 PREINIT:
512 11 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 11 0 11
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 11 11
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 11 11
513 CODE:
514 11 RETVAL = pubsub_eventfd_create(h);
515 11 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 11 11
516 OUTPUT:
517 RETVAL
518  
519 void
520 eventfd_set(self, fd)
521 SV *self
522 int fd
523 PREINIT:
524 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
525 CODE:
526 6 ▶ if (pubsub_eventfd_set(h, fd) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_eventfd_set(h, fd) < 0) 1 5 6
527 1 croak("eventfd_set: %s", strerror(errno));
528  
529 IV
530 fileno(self)
531 SV *self
532 PREINIT:
533 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
534 CODE:
535 6 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 0 6 6
536 OUTPUT:
537 RETVAL
538  
539 SV *
540 eventfd_consume(self)
541 SV *self
542 PREINIT:
543 8 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 8 0 8
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 8 8
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 8 8
544 CODE:
545 8 int64_t v = pubsub_eventfd_consume(h);
546 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
547 OUTPUT:
548 RETVAL
549  
550 void
551 notify(self)
552 SV *self
553 PREINIT:
554 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Int", self); 0 6 6
555 CODE:
556 6 pubsub_notify(h);
557  
558 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int::Sub
559  
560 void
561 DESTROY(self)
562 SV *self
563 CODE:
564 50 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int::Sub")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int::Sub")) return; 50 0 50
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int::Sub")) return; 0 50 50
565 50 PubSubSub *sub = INT2PTR(PubSubSub*, SvIV(SvRV(self)));
566 50 ▶ if (!sub) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) return; 0 50 50
567 50 sv_setiv(SvRV(self), 0);
568 50 ▶ if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata);
Branch: 1 branch
BranchTrueFalseTotal
if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata); 50 0 50
569 50 pubsub_sub_destroy(sub);
570  
571 SV *
572 poll(self)
573 SV *self
574 PREINIT:
575 38 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 38 0 38
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 38 38
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 38 38
576 int64_t value;
577 CODE:
578 38 int r = pubsub_int_poll(sub, &value);
579 38 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 33 5 38
580 33 RETVAL = newSViv((IV)value);
581 else
582 5 RETVAL = &PL_sv_undef;
583 OUTPUT:
584 RETVAL
585  
586 void
587 poll_multi(self, count)
588 SV *self
589 UV count
590 PREINIT:
591 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
592 int64_t value;
593 PPCODE:
594 12 ▶ for (UV i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < count; i++) { 10 2 12
595 10 int r = pubsub_int_poll(sub, &value);
596 10 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 0 10 10
597 10 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 10 10
598 }
599  
600 SV *
601 poll_wait(self, ...)
602 SV *self
603 PREINIT:
604 9 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 9 0 9
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 9 9
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 9 9
605 9 double timeout = -1;
606 int64_t value;
607 CODE:
608 9 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 9 0 9
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 9 9
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 9 0 9
609 9 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 9 9
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 9 9
610 9 int r = pubsub_perl_int_poll_wait(aTHX_ self, sub, &value, timeout);
611 9 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 8 1 9
612 8 RETVAL = newSViv((IV)value);
613 else
614 1 RETVAL = &PL_sv_undef;
615 OUTPUT:
616 RETVAL
617  
618 void
619 drain(self, ...)
620 SV *self
621 PREINIT:
622 8 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 8 0 8
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 8 8
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 8 8
623 int64_t value;
624 uint32_t max_count;
625 PPCODE:
626 8 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 1 7 8
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 1 1
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 1 0 1
627 8 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 8 8
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 8 8
628 1028 ▶ while (max_count-- > 0 && pubsub_int_poll(sub, &value))
Branch: 2 branches
BranchTrueFalseTotal
while (max_count-- > 0 && pubsub_int_poll(sub, &value)) 1027 1 1028
while (max_count-- > 0 && pubsub_int_poll(sub, &value)) 1020 7 1027
629 1020 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 1020 1020
630  
631 void
632 poll_wait_multi(self, count, ...)
633 SV *self
634 UV count
635 PREINIT:
636 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
637 3 double timeout = -1;
638 int64_t value;
639 PPCODE:
640 3 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 1 2 3
641 2 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 2 0 2
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 2 2
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 2 0 2
642 2 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
643 2 ▶ if (!pubsub_perl_int_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_perl_int_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0); 1 1 2
644 1 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 1 1
645 5 ▶ for (UV i = 1; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 1; i < count; i++) { 4 1 5
646 4 ▶ if (!pubsub_int_poll(sub, &value)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_int_poll(sub, &value)) break; 0 4 4
647 4 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 4 4
648 }
649  
650 UV
651 lag(self)
652 SV *self
653 PREINIT:
654 18 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 18 0 18
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 18 18
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 18 18
655 CODE:
656 18 RETVAL = (UV)pubsub_lag(sub);
657 OUTPUT:
658 RETVAL
659  
660 UV
661 overflow_count(self)
662 SV *self
663 PREINIT:
664 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
665 CODE:
666 2 ▶ RETVAL = (UV)sub->overflow_count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->overflow_count; 0 2 2
667 OUTPUT:
668 RETVAL
669  
670 UV
671 write_pos(self)
672 SV *self
673 PREINIT:
674 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
675 CODE:
676 2 ▶ RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED); 0 2 2
677 OUTPUT:
678 RETVAL
679  
680 bool
681 has_overflow(self)
682 SV *self
683 PREINIT:
684 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
685 CODE:
686 2 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
687 2 ▶ RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 1 2
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 1 2
688 OUTPUT:
689 RETVAL
690  
691 UV
692 cursor(self, ...)
693 SV *self
694 PREINIT:
695 6 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 6 0 6
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 6 6
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 6 6
696 CODE:
697 6 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) {
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 2 4 6
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 2 2
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 2 0 2
698 2 uint64_t new_cursor = (uint64_t)SvUV(ST(1));
699 2 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
700 2 sub->cursor = new_cursor;
701 }
702 6 ▶ RETVAL = (UV)sub->cursor;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->cursor; 0 6 6
703 OUTPUT:
704 RETVAL
705  
706 void
707 reset(self)
708 SV *self
709 PREINIT:
710 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 1 1
711 CODE:
712 1 sub->cursor = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
713  
714 void
715 reset_oldest(self)
716 SV *self
717 PREINIT:
718 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 2 2
719 CODE:
720 2 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
721 2 ▶ sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0;
Branch: 1 branch
BranchTrueFalseTotal
sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0; 0 2 2
722  
723 UV
724 poll_cb(self, cb)
725 SV *self
726 SV *cb
727 PREINIT:
728 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
729 int64_t value;
730 CODE:
731 3 RETVAL = 0;
732 /* Keep the backing handle alive across the callback: a callback that
733 * drops self's last reference would free `sub` mid-loop (UAF). Guard
734 * the referent (the blessed handle), not the RV container -- assigning
735 * undef to self overwrites the container and frees the referent. */
736 3 SV *psx_guard = SvRV(self);
737 3 SvREFCNT_inc_simple_void_NN(psx_guard);
738 3 SAVEFREESV(psx_guard);
739 108 ▶ while (pubsub_int_poll(sub, &value)) {
Branch: 1 branch
BranchTrueFalseTotal
while (pubsub_int_poll(sub, &value)) { 105 3 108
740 105 dSP;
741 105 ENTER; SAVETMPS;
742 105 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 105 105
743 105 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 105 105
744 105 PUTBACK;
745 105 call_sv(cb, G_DISCARD);
746 105 ▶ FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; LEAVE; 105 0 105
747 /* call_sv ran arbitrary Perl: the callback may have DESTROYed or
748 * replaced the subscriber. Re-extract before the next poll. */
749 105 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 105 105
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 105 105
750 105 RETVAL++;
751 }
752 OUTPUT:
753 RETVAL
754  
755 void
756 drain_notify(self, ...)
757 SV *self
758 PREINIT:
759 5 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 5 0 5
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 5 5
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 5 5
760 int64_t value;
761 uint32_t max_count;
762 PPCODE:
763 5 pubsub_sub_eventfd_consume(sub);
764 5 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 3 2 5
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 3 3
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 3 0 3
765 5 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 5 5
REEXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 5 5
766 15 ▶ while (max_count > 0 && pubsub_int_poll(sub, &value)) {
Branch: 2 branches
BranchTrueFalseTotal
while (max_count > 0 && pubsub_int_poll(sub, &value)) { 13 2 15
while (max_count > 0 && pubsub_int_poll(sub, &value)) { 10 3 13
767 10 max_count--;
768 10 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 10 10
769 }
770 5 ▶ if (max_count == 0 && pubsub_lag(sub) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (max_count == 0 && pubsub_lag(sub) > 0) 2 3 5
if (max_count == 0 && pubsub_lag(sub) > 0) 2 0 2
771 2 pubsub_notify_fd(sub->notify_fd);
772  
773 void
774 eventfd_set(self, fd)
775 SV *self
776 int fd
777 PREINIT:
778 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 1 1
779 CODE:
780 1 sub->notify_fd = fd;
781  
782 IV
783 fileno(self)
784 SV *self
785 PREINIT:
786 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Int::Sub", self); 0 3 3
787 CODE:
788 3 ▶ RETVAL = sub->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = sub->notify_fd; 0 3 3
789 OUTPUT:
790 RETVAL
791  
792 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Str
793  
794 SV *
795 new(class, path, capacity, ...)
796 const char *class
797 SV *path
798 UV capacity
799 PREINIT:
800 char errbuf[PUBSUB_ERR_BUFLEN];
801 uint32_t msg_size;
802 CODE:
803 61 ▶ msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0;
Branch: 4 branches
BranchTrueFalseTotal
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 22 39 61
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 22 22
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 0 0
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 22 0 22
804 61 ▶ mode_t fmode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 61 61
mode_t fmode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
mode_t fmode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
mode_t fmode = (items > 4 && (SvGETMAGIC(ST(4)), SvOK(ST(4)))) ? (mode_t)SvUV(ST(4)) : 0600; 0 0 0
805 76 ▶ 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 61 61
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; 15 46 61
806 61 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 61 61
807 61 PubSubHandle *h = pubsub_create(p, (uint32_t)capacity, PUBSUB_MODE_STR, msg_size, fmode, errbuf);
808 61 ▶ if (!h) croak("Data::PubSub::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 60 61
if (!h) croak("Data::PubSub::Shared::Str->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
809 60 MAKE_OBJ(class, h);
810 OUTPUT:
811 RETVAL
812  
813 SV *
814 new_memfd(class, name, capacity, ...)
815 const char *class
816 const char *name
817 UV capacity
818 PREINIT:
819 char errbuf[PUBSUB_ERR_BUFLEN];
820 uint32_t msg_size;
821 CODE:
822 2 ▶ msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0;
Branch: 4 branches
BranchTrueFalseTotal
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 2 2
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 0 0
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 0 0
msg_size = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (uint32_t)SvUV(ST(3)) : 0; 0 0 0
823 2 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 2 2
824 2 PubSubHandle *h = pubsub_create_memfd(name, (uint32_t)capacity, PUBSUB_MODE_STR, msg_size, errbuf);
825 2 ▶ if (!h) croak("Data::PubSub::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Str->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
826 2 MAKE_OBJ(class, h);
827 OUTPUT:
828 RETVAL
829  
830 SV *
831 new_from_fd(class, fd)
832 const char *class
833 int fd
834 PREINIT:
835 char errbuf[PUBSUB_ERR_BUFLEN];
836 CODE:
837 2 PubSubHandle *h = pubsub_open_fd(fd, PUBSUB_MODE_STR, errbuf);
838 2 ▶ if (!h) croak("Data::PubSub::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Str->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
839 2 MAKE_OBJ(class, h);
840 OUTPUT:
841 RETVAL
842  
843 IV
844 memfd(self)
845 SV *self
846 PREINIT:
847 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
848 CODE:
849 2 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 1 1 2
850 OUTPUT:
851 RETVAL
852  
853 void
854 DESTROY(self)
855 SV *self
856 CODE:
857 64 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str")) return; 64 0 64
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str")) return; 0 64 64
858 64 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self)));
859 64 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 64 64
860 64 sv_setiv(SvRV(self), 0);
861 64 pubsub_destroy(h);
862  
863 SV *
864 publish(self, value)
865 SV *self
866 SV *value
867 PREINIT:
868 393 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 393 0 393
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 393 393
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 393 393
869 CODE:
870 STRLEN len;
871 393 ▶ SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */ 0 393 393
SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */ 0 0 0
872 393 const char *str = SvPV_nomg(value, len);
873 393 bool utf8 = SvUTF8(value) ? true : false;
874 393 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 393 393
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 393 393
875 393 ▶ int r = pubsub_perl_str_publish(aTHX_ self, h, str, LEN32(len), utf8);
Branch: 1 branch
BranchTrueFalseTotal
int r = pubsub_perl_str_publish(aTHX_ self, h, str, LEN32(len), utf8); 393 0 393
876 393 ▶ if (r == -1) croak("publish: message too long (%u > %u)", (unsigned)len, h->msg_size);
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) croak("publish: message too long (%u > %u)", (unsigned)len, h->msg_size); 2 391 393
877 391 RETVAL = &PL_sv_yes;
878 OUTPUT:
879 RETVAL
880  
881 UV
882 publish_multi(self, ...)
883 SV *self
884 PREINIT:
885 8 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 8 0 8
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 8 8
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 8 8
886 CODE:
887 8 RETVAL = 0;
888 8 uint32_t count = items - 1;
889 8 ▶ if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count); 0 8 8
890 8 ▶ if (count > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (count > 0) { 7 1 8
891 /* Extract SV data BEFORE locking: SvPV(utf8) can run magic
892 * (tied/overloaded stringification) that longjmps; doing it under
893 * the process-shared mutex would abandon the lock and deadlock peers.
894 * Newx+SAVEFREEPV so a die during extraction cannot leak args. */
895 struct psm_arg { const char *str; STRLEN len; bool utf8; };
896 struct psm_arg *args;
897 7 Newx(args, count, struct psm_arg);
898 7 SAVEFREEPV(args);
899 28 ▶ for (uint32_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) { 21 7 28
900 21 SV *val = ST(i + 1);
901 21 ▶ SvGETMAGIC(val);
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(val); 0 21 21
SvGETMAGIC(val); 0 0 0
902 STRLEN len;
903 21 const char *src = SvPV_nomg(val, len);
904 /* Copy bytes into a private mortal SV NOW: a LATER element's
905 * SvGETMAGIC (tied/overloaded) can run arbitrary Perl that
906 * grows/frees THIS element's PV, dangling src before the locked
907 * loop memcpys it. The mortal lives until FREETMPS after the loop. */
908 21 SV *copy = sv_2mortal(newSVpvn(src, len));
909 21 args[i].utf8 = SvUTF8(val) ? true : false;
910 21 args[i].str = SvPVX_const(copy);
911 21 args[i].len = len;
912 }
913 7 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 7 7
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 7 7
914 7 pubsub_perl_mutex_lock(aTHX_ self, h);
915 26 ▶ for (uint32_t i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) { 21 5 26
916 21 ▶ int r = pubsub_str_publish_locked(h, args[i].str, LEN32(args[i].len), args[i].utf8);
Branch: 1 branch
BranchTrueFalseTotal
int r = pubsub_str_publish_locked(h, args[i].str, LEN32(args[i].len), args[i].utf8); 21 0 21
917 21 ▶ if (r == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) { 2 19 21
918 2 pubsub_mutex_unlock(h->hdr);
919 2 ▶ if (RETVAL) pubsub_wake_subscribers_fenced(h->hdr);
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL) pubsub_wake_subscribers_fenced(h->hdr); 2 0 2
920 2 croak("publish_multi: message too long (%u > %u)", (unsigned)args[i].len, h->msg_size);
921 }
922 19 RETVAL++;
923 }
924 5 pubsub_mutex_unlock(h->hdr);
925 5 pubsub_wake_subscribers_fenced(h->hdr);
926 }
927 OUTPUT:
928 RETVAL
929  
930 void
931 publish_notify(self, value)
932 SV *self
933 SV *value
934 PREINIT:
935 3 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 3 0 3
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 3 3
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 3 3
936 CODE:
937 STRLEN len;
938 3 ▶ SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */
Branch: 2 branches
BranchTrueFalseTotal
SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */ 0 3 3
SvGETMAGIC(value); /* run get-magic/overload before reading the UTF8 flag */ 0 0 0
939 3 const char *str = SvPV_nomg(value, len);
940 3 bool utf8 = SvUTF8(value) ? true : false;
941 3 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 3 3
REEXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 3 3
942 3 ▶ int r = pubsub_perl_str_publish(aTHX_ self, h, str, LEN32(len), utf8);
Branch: 1 branch
BranchTrueFalseTotal
int r = pubsub_perl_str_publish(aTHX_ self, h, str, LEN32(len), utf8); 3 0 3
943 3 ▶ if (r == -1) croak("publish_notify: message too long (%u > %u)", (unsigned)len, h->msg_size);
Branch: 1 branch
BranchTrueFalseTotal
if (r == -1) croak("publish_notify: message too long (%u > %u)", (unsigned)len, h->msg_size); 0 3 3
944 3 pubsub_notify(h);
945  
946 SV *
947 subscribe(self)
948 SV *self
949 PREINIT:
950 220 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 220 0 220
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 220 220
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 220 220
951 CODE:
952 220 PubSubSub *sub = pubsub_subscribe(h, 0);
953 220 ▶ if (!sub) croak("subscribe: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe: out of memory"); 0 220 220
954 220 sub->userdata = (void *)newSVsv(self);
955 220 MAKE_OBJ("Data::PubSub::Shared::Str::Sub", sub);
956 OUTPUT:
957 RETVAL
958  
959 SV *
960 subscribe_all(self)
961 SV *self
962 PREINIT:
963 27 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 27 0 27
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 27 27
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 27 27
964 CODE:
965 27 PubSubSub *sub = pubsub_subscribe(h, 1);
966 27 ▶ if (!sub) croak("subscribe_all: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe_all: out of memory"); 0 27 27
967 27 sub->userdata = (void *)newSVsv(self);
968 27 MAKE_OBJ("Data::PubSub::Shared::Str::Sub", sub);
969 OUTPUT:
970 RETVAL
971  
972 UV
973 capacity(self)
974 SV *self
975 PREINIT:
976 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 1 1
977 CODE:
978 1 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 0 1 1
979 OUTPUT:
980 RETVAL
981  
982 UV
983 msg_size(self)
984 SV *self
985 PREINIT:
986 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
987 CODE:
988 2 ▶ RETVAL = h->msg_size;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->msg_size; 0 2 2
989 OUTPUT:
990 RETVAL
991  
992 UV
993 write_pos(self)
994 SV *self
995 PREINIT:
996 7 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 7 0 7
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 7 7
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 7 7
997 CODE:
998 7 ▶ RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED); 0 7 7
999 OUTPUT:
1000 RETVAL
1001  
1002 SV *
1003 path(self)
1004 SV *self
1005 PREINIT:
1006 0 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 0 0
1007 CODE:
1008 0 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 0 0 0
1009 OUTPUT:
1010 RETVAL
1011  
1012 SV *
1013 stats(self)
1014 SV *self
1015 PREINIT:
1016 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 4 4
1017 CODE:
1018 4 HV *hv = newHV();
1019 4 PubSubHeader *hdr = h->hdr;
1020 4 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
1021 4 hv_store(hv, "msg_size", 8, newSVuv(h->msg_size), 0);
1022 4 hv_store(hv, "arena_cap", 9, newSVuv((UV)h->arena_cap), 0);
1023 4 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
1024 4 hv_store(hv, "write_pos", 9,
1025 newSVuv((UV)__atomic_load_n(&hdr->write_pos, __ATOMIC_RELAXED)), 0);
1026 4 hv_store(hv, "publish_ok", 10,
1027 newSVuv((UV)__atomic_load_n(&hdr->stat_publish_ok, __ATOMIC_RELAXED)), 0);
1028 4 hv_store(hv, "recoveries", 10,
1029 newSVuv(__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
1030 4 hv_store(hv, "sub_waiters", 11,
1031 newSVuv(__atomic_load_n(&hdr->sub_waiters, __ATOMIC_RELAXED)), 0);
1032 4 RETVAL = newRV_noinc((SV *)hv);
1033 OUTPUT:
1034 RETVAL
1035  
1036 void
1037 clear(self)
1038 SV *self
1039 PREINIT:
1040 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
1041 CODE:
1042 2 pubsub_perl_mutex_lock(aTHX_ self, h);
1043 2 pubsub_clear_locked(h);
1044 2 pubsub_mutex_unlock(h->hdr);
1045  
1046 void
1047 sync(self)
1048 SV *self
1049 PREINIT:
1050 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 2 2
1051 CODE:
1052 2 ▶ if (pubsub_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_sync(h) != 0) 0 2 2
1053 0 croak("msync: %s", strerror(errno));
1054  
1055 void
1056 unlink(self_or_class, ...)
1057 SV *self_or_class
1058 CODE:
1059 const char *path;
1060 1 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Str")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Str")) { 1 0 1
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Str")) { 1 0 1
1061 1 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self_or_class)));
1062 1 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 1 1
1063 1 path = h->path;
1064 } else {
1065 0 ▶ if (items < 2) croak("Usage: Data::PubSub::Shared::Str->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::PubSub::Shared::Str->unlink($path)"); 0 0 0
1066 0 path = SvPV_nolen(ST(1));
1067 }
1068 1 ▶ if (!path) croak("cannot unlink anonymous or memfd pubsub");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd pubsub"); 0 1 1
1069 1 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 1 1
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
1070 0 croak("unlink(%s): %s", path, strerror(errno));
1071  
1072 IV
1073 eventfd(self)
1074 SV *self
1075 PREINIT:
1076 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 6 6
1077 CODE:
1078 6 RETVAL = pubsub_eventfd_create(h);
1079 6 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 6 6
1080 OUTPUT:
1081 RETVAL
1082  
1083 void
1084 eventfd_set(self, fd)
1085 SV *self
1086 int fd
1087 PREINIT:
1088 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 5 5
1089 CODE:
1090 5 ▶ if (pubsub_eventfd_set(h, fd) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_eventfd_set(h, fd) < 0) 1 4 5
1091 1 croak("eventfd_set: %s", strerror(errno));
1092  
1093 IV
1094 fileno(self)
1095 SV *self
1096 PREINIT:
1097 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 5 5
1098 CODE:
1099 5 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 5 0 5
1100 OUTPUT:
1101 RETVAL
1102  
1103 SV *
1104 eventfd_consume(self)
1105 SV *self
1106 PREINIT:
1107 6 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 6 0 6
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 6 6
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 6 6
1108 CODE:
1109 6 int64_t v = pubsub_eventfd_consume(h);
1110 6 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 5 1 6
1111 OUTPUT:
1112 RETVAL
1113  
1114 void
1115 notify(self)
1116 SV *self
1117 PREINIT:
1118 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Str", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Str", self); 0 4 4
1119 CODE:
1120 4 pubsub_notify(h);
1121  
1122 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Str::Sub
1123  
1124 void
1125 DESTROY(self)
1126 SV *self
1127 CODE:
1128 247 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str::Sub")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str::Sub")) return; 247 0 247
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Str::Sub")) return; 0 247 247
1129 247 PubSubSub *sub = INT2PTR(PubSubSub*, SvIV(SvRV(self)));
1130 247 ▶ if (!sub) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) return; 0 247 247
1131 247 sv_setiv(SvRV(self), 0);
1132 247 ▶ if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata);
Branch: 1 branch
BranchTrueFalseTotal
if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata); 247 0 247
1133 247 pubsub_sub_destroy(sub);
1134  
1135 SV *
1136 poll(self)
1137 SV *self
1138 PREINIT:
1139 884 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 884 0 884
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 884 884
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 884 884
1140 const char *str;
1141 uint32_t len;
1142 bool utf8;
1143 CODE:
1144 884 int r = pubsub_str_poll(sub, &str, &len, &utf8);
1145 884 ▶ if (r == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) { 881 3 884
1146 881 RETVAL = newSVpvn(str, len);
1147 881 ▶ if (utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(RETVAL); 5 876 881
1148 } else {
1149 3 RETVAL = &PL_sv_undef;
1150 }
1151 OUTPUT:
1152 RETVAL
1153  
1154 void
1155 poll_multi(self, count)
1156 SV *self
1157 UV count
1158 PREINIT:
1159 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1160 const char *str;
1161 uint32_t len;
1162 bool utf8;
1163 PPCODE:
1164 4 ▶ for (UV i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < count; i++) { 4 0 4
1165 4 int r = pubsub_str_poll(sub, &str, &len, &utf8);
1166 4 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 1 3 4
1167 3 SV *sv = newSVpvn(str, len);
1168 3 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 0 3 3
1169 3 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 3 3
1170 }
1171  
1172 SV *
1173 poll_wait(self, ...)
1174 SV *self
1175 PREINIT:
1176 54 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 54 0 54
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 54 54
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 54 54
1177 54 double timeout = -1;
1178 const char *str;
1179 uint32_t len;
1180 bool utf8;
1181 CODE:
1182 54 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 54 0 54
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 54 54
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 54 0 54
1183 54 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 54 54
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 54 54
1184 54 int r = pubsub_perl_str_poll_wait(aTHX_ self, sub, &str, &len, &utf8, timeout);
1185 54 ▶ if (r == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) { 53 1 54
1186 53 RETVAL = newSVpvn(str, len);
1187 53 ▶ if (utf8) SvUTF8_on(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(RETVAL); 0 53 53
1188 } else {
1189 1 RETVAL = &PL_sv_undef;
1190 }
1191 OUTPUT:
1192 RETVAL
1193  
1194 void
1195 drain(self, ...)
1196 SV *self
1197 PREINIT:
1198 4 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 4 0 4
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
1199 const char *str;
1200 uint32_t len;
1201 bool utf8;
1202 uint32_t max_count;
1203 PPCODE:
1204 4 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 4 4
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
1205 4 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
1206 20 ▶ while (max_count-- > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
while (max_count-- > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) { 20 0 20
while (max_count-- > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) { 16 4 20
1207 16 SV *sv = newSVpvn(str, len);
1208 16 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 0 16 16
1209 16 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 16 16
1210 }
1211  
1212 void
1213 poll_wait_multi(self, count, ...)
1214 SV *self
1215 UV count
1216 PREINIT:
1217 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
1218 2 double timeout = -1;
1219 const char *str;
1220 uint32_t len;
1221 bool utf8;
1222 PPCODE:
1223 2 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 1 1 2
1224 1 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 1 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
1225 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1226 1 ▶ if (pubsub_perl_str_poll_wait(aTHX_ self, sub, &str, &len, &utf8, timeout) != 1) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_perl_str_poll_wait(aTHX_ self, sub, &str, &len, &utf8, timeout) != 1) XSRETURN(0); 0 1 1
1227 {
1228 1 SV *sv = newSVpvn(str, len);
1229 1 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 0 1 1
1230 1 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 1 1
1231 }
1232 3 ▶ for (UV i = 1; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 1; i < count; i++) { 2 1 3
1233 2 ▶ if (pubsub_str_poll(sub, &str, &len, &utf8) != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_str_poll(sub, &str, &len, &utf8) != 1) break; 0 2 2
1234 2 SV *sv = newSVpvn(str, len);
1235 2 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 0 2 2
1236 2 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 2 2
1237 }
1238  
1239 UV
1240 lag(self)
1241 SV *self
1242 PREINIT:
1243 8 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 8 0 8
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 8 8
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 8 8
1244 CODE:
1245 8 RETVAL = (UV)pubsub_lag(sub);
1246 OUTPUT:
1247 RETVAL
1248  
1249 UV
1250 overflow_count(self)
1251 SV *self
1252 PREINIT:
1253 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1254 CODE:
1255 1 ▶ RETVAL = (UV)sub->overflow_count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->overflow_count; 0 1 1
1256 OUTPUT:
1257 RETVAL
1258  
1259 UV
1260 write_pos(self)
1261 SV *self
1262 PREINIT:
1263 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1264 CODE:
1265 1 ▶ RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED); 0 1 1
1266 OUTPUT:
1267 RETVAL
1268  
1269 bool
1270 has_overflow(self)
1271 SV *self
1272 PREINIT:
1273 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
1274 CODE:
1275 2 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
1276 2 ▶ RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 1 2
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 1 2
1277 OUTPUT:
1278 RETVAL
1279  
1280 UV
1281 cursor(self, ...)
1282 SV *self
1283 PREINIT:
1284 848 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 848 0 848
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 848 848
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 848 848
1285 CODE:
1286 848 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) {
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 846 2 848
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 846 846
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 846 0 846
1287 846 uint64_t new_cursor = (uint64_t)SvUV(ST(1));
1288 846 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 846 846
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 846 846
1289 846 sub->cursor = new_cursor;
1290 }
1291 848 ▶ RETVAL = (UV)sub->cursor;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->cursor; 843 5 848
1292 OUTPUT:
1293 RETVAL
1294  
1295 void
1296 reset(self)
1297 SV *self
1298 PREINIT:
1299 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1300 CODE:
1301 1 sub->cursor = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
1302  
1303 void
1304 reset_oldest(self)
1305 SV *self
1306 PREINIT:
1307 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1308 CODE:
1309 1 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
1310 1 ▶ sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0;
Branch: 1 branch
BranchTrueFalseTotal
sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0; 0 1 1
1311  
1312 UV
1313 poll_cb(self, cb)
1314 SV *self
1315 SV *cb
1316 PREINIT:
1317 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 2 2
1318 const char *str;
1319 uint32_t len;
1320 bool utf8;
1321 CODE:
1322 2 RETVAL = 0;
1323 /* Keep the backing handle alive across the callback: a callback that
1324 * drops self's last reference would free `sub` mid-loop (UAF). Guard
1325 * the referent (the blessed handle), not the RV container -- assigning
1326 * undef to self overwrites the container and frees the referent. */
1327 2 SV *psx_guard = SvRV(self);
1328 2 SvREFCNT_inc_simple_void_NN(psx_guard);
1329 2 SAVEFREESV(psx_guard);
1330 6 ▶ while (pubsub_str_poll(sub, &str, &len, &utf8) == 1) {
Branch: 1 branch
BranchTrueFalseTotal
while (pubsub_str_poll(sub, &str, &len, &utf8) == 1) { 4 2 6
1331 4 dSP;
1332 4 ENTER; SAVETMPS;
1333 4 SV *sv = newSVpvn(str, len);
1334 4 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 1 3 4
1335 4 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 4 4
1336 4 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 4 4
1337 4 PUTBACK;
1338 4 call_sv(cb, G_DISCARD);
1339 4 ▶ FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; LEAVE; 4 0 4
1340 /* call_sv ran arbitrary Perl: the callback may have DESTROYed or
1341 * replaced the subscriber. Re-extract before the next poll. */
1342 4 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 4 4
1343 4 RETVAL++;
1344 }
1345 OUTPUT:
1346 RETVAL
1347  
1348 void
1349 drain_notify(self, ...)
1350 SV *self
1351 PREINIT:
1352 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 3 3
1353 const char *str;
1354 uint32_t len;
1355 bool utf8;
1356 uint32_t max_count;
1357 PPCODE:
1358 3 pubsub_sub_eventfd_consume(sub);
1359 3 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 1 3
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 2 2
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 0 2
1360 3 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 3 3
REEXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 3 3
1361 9 ▶ while (max_count > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) {
Branch: 2 branches
BranchTrueFalseTotal
while (max_count > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) { 8 1 9
while (max_count > 0 && pubsub_str_poll(sub, &str, &len, &utf8) == 1) { 6 2 8
1362 6 max_count--;
1363 6 SV *sv = newSVpvn(str, len);
1364 6 ▶ if (utf8) SvUTF8_on(sv);
Branch: 1 branch
BranchTrueFalseTotal
if (utf8) SvUTF8_on(sv); 0 6 6
1365 6 ▶ mXPUSHs(sv);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHs(sv); 0 6 6
1366 }
1367 3 ▶ if (max_count == 0 && pubsub_lag(sub) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (max_count == 0 && pubsub_lag(sub) > 0) 1 2 3
if (max_count == 0 && pubsub_lag(sub) > 0) 1 0 1
1368 1 pubsub_notify_fd(sub->notify_fd);
1369  
1370 void
1371 eventfd_set(self, fd)
1372 SV *self
1373 int fd
1374 PREINIT:
1375 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 0 0
1376 CODE:
1377 0 sub->notify_fd = fd;
1378  
1379 IV
1380 fileno(self)
1381 SV *self
1382 PREINIT:
1383 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Str::Sub", self); 0 1 1
1384 CODE:
1385 1 ▶ RETVAL = sub->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = sub->notify_fd; 0 1 1
1386 OUTPUT:
1387 RETVAL
1388  
1389 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int32
1390  
1391 SV *
1392 new(class, path, capacity, ...)
1393 const char *class
1394 SV *path
1395 UV capacity
1396 PREINIT:
1397 char errbuf[PUBSUB_ERR_BUFLEN];
1398 CODE:
1399 13 ▶ mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 13 13
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
1400 15 ▶ 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 13 13
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; 2 11 13
1401 13 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 13 13
1402 13 PubSubHandle *h = pubsub_create(p, (uint32_t)capacity, PUBSUB_MODE_INT32, 0, fmode, errbuf);
1403 13 ▶ if (!h) croak("Data::PubSub::Shared::Int32->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int32->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 12 13
if (!h) croak("Data::PubSub::Shared::Int32->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
1404 12 MAKE_OBJ(class, h);
1405 OUTPUT:
1406 RETVAL
1407  
1408 SV *
1409 new_memfd(class, name, capacity)
1410 const char *class
1411 const char *name
1412 UV capacity
1413 PREINIT:
1414 char errbuf[PUBSUB_ERR_BUFLEN];
1415 CODE:
1416 2 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 2 2
1417 2 PubSubHandle *h = pubsub_create_memfd(name, (uint32_t)capacity, PUBSUB_MODE_INT32, 0, errbuf);
1418 2 ▶ if (!h) croak("Data::PubSub::Shared::Int32->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int32->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int32->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
1419 2 MAKE_OBJ(class, h);
1420 OUTPUT:
1421 RETVAL
1422  
1423 SV *
1424 new_from_fd(class, fd)
1425 const char *class
1426 int fd
1427 PREINIT:
1428 char errbuf[PUBSUB_ERR_BUFLEN];
1429 CODE:
1430 2 PubSubHandle *h = pubsub_open_fd(fd, PUBSUB_MODE_INT32, errbuf);
1431 2 ▶ if (!h) croak("Data::PubSub::Shared::Int32->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int32->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int32->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
1432 2 MAKE_OBJ(class, h);
1433 OUTPUT:
1434 RETVAL
1435  
1436 IV
1437 memfd(self)
1438 SV *self
1439 PREINIT:
1440 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1441 CODE:
1442 2 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 1 1 2
1443 OUTPUT:
1444 RETVAL
1445  
1446 void
1447 DESTROY(self)
1448 SV *self
1449 CODE:
1450 16 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32")) return; 16 0 16
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32")) return; 0 16 16
1451 16 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self)));
1452 16 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 16 16
1453 16 sv_setiv(SvRV(self), 0);
1454 16 pubsub_destroy(h);
1455  
1456 bool
1457 publish(self, value)
1458 SV *self
1459 IV value
1460 PREINIT:
1461 50 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 50 0 50
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 50 50
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 50 50
1462 CODE:
1463 50 ▶ RETVAL = pubsub_int32_publish(h, (int32_t)value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pubsub_int32_publish(h, (int32_t)value); 50 0 50
1464 OUTPUT:
1465 RETVAL
1466  
1467 #ifdef PUBSUB_TEST_HOOKS
1468  
1469 void
1470 _publish_at(self, pos, value)
1471 SV *self
1472 UV pos
1473 IV value
1474 PREINIT:
1475 EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
1476 CODE:
1477 pubsub_int32_commit_at(h, (uint64_t)pos, (int32_t)value);
1478  
1479 UV
1480 _slot_seq(self, pos)
1481 SV *self
1482 UV pos
1483 PREINIT:
1484 EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
1485 CODE:
1486 RETVAL = (UV)((PubSubInt32Slot *)h->slots)[pos & h->cap_mask].sequence;
1487 OUTPUT:
1488 RETVAL
1489  
1490 #endif
1491  
1492 UV
1493 publish_multi(self, ...)
1494 SV *self
1495 PREINIT:
1496 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1497 CODE:
1498 2 uint32_t count = items - 1;
1499 2 ▶ if (count == 0) { RETVAL = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) { RETVAL = 0; } 0 2 2
1500 else {
1501 2 ▶ if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count); 0 2 2
1502 2 int32_t *vals = (int32_t *)alloca(count * sizeof(int32_t));
1503 10 ▶ for (uint32_t i = 0; i < count; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) 8 2 10
1504 8 vals[i] = (int32_t)SvIV(ST(i + 1));
1505 2 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
REEXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1506 2 RETVAL = pubsub_int32_publish_multi(h, vals, count);
1507 }
1508 OUTPUT:
1509 RETVAL
1510  
1511 void
1512 publish_notify(self, value)
1513 SV *self
1514 IV value
1515 PREINIT:
1516 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
1517 CODE:
1518 1 pubsub_int32_publish(h, (int32_t)value);
1519 1 pubsub_notify(h);
1520  
1521 SV *
1522 subscribe(self)
1523 SV *self
1524 PREINIT:
1525 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
1526 CODE:
1527 5 PubSubSub *sub = pubsub_subscribe(h, 0);
1528 5 ▶ if (!sub) croak("subscribe: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe: out of memory"); 0 5 5
1529 5 sub->userdata = (void *)newSVsv(self);
1530 5 MAKE_OBJ("Data::PubSub::Shared::Int32::Sub", sub);
1531 OUTPUT:
1532 RETVAL
1533  
1534 SV *
1535 subscribe_all(self)
1536 SV *self
1537 PREINIT:
1538 7 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 7 0 7
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 7 7
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 7 7
1539 CODE:
1540 7 PubSubSub *sub = pubsub_subscribe(h, 1);
1541 7 ▶ if (!sub) croak("subscribe_all: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe_all: out of memory"); 0 7 7
1542 7 sub->userdata = (void *)newSVsv(self);
1543 7 MAKE_OBJ("Data::PubSub::Shared::Int32::Sub", sub);
1544 OUTPUT:
1545 RETVAL
1546  
1547 UV
1548 capacity(self)
1549 SV *self
1550 PREINIT:
1551 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
1552 CODE:
1553 1 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 0 1 1
1554 OUTPUT:
1555 RETVAL
1556  
1557 UV
1558 write_pos(self)
1559 SV *self
1560 PREINIT:
1561 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 4 4
1562 CODE:
1563 4 ▶ RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED); 0 4 4
1564 OUTPUT:
1565 RETVAL
1566  
1567 SV *
1568 path(self)
1569 SV *self
1570 PREINIT:
1571 0 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 0 0
1572 CODE:
1573 0 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 0 0 0
1574 OUTPUT:
1575 RETVAL
1576  
1577 SV *
1578 stats(self)
1579 SV *self
1580 PREINIT:
1581 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1582 CODE:
1583 2 HV *hv = newHV();
1584 2 PubSubHeader *hdr = h->hdr;
1585 2 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
1586 2 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
1587 2 hv_store(hv, "write_pos", 9,
1588 newSVuv((UV)__atomic_load_n(&hdr->write_pos, __ATOMIC_RELAXED)), 0);
1589 2 hv_store(hv, "publish_ok", 10,
1590 newSVuv((UV)__atomic_load_n(&hdr->stat_publish_ok, __ATOMIC_RELAXED)), 0);
1591 2 hv_store(hv, "recoveries", 10,
1592 newSVuv(__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
1593 2 hv_store(hv, "sub_waiters", 11,
1594 newSVuv(__atomic_load_n(&hdr->sub_waiters, __ATOMIC_RELAXED)), 0);
1595 2 RETVAL = newRV_noinc((SV *)hv);
1596 OUTPUT:
1597 RETVAL
1598  
1599 void
1600 clear(self)
1601 SV *self
1602 PREINIT:
1603 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
1604 CODE:
1605 1 pubsub_clear(h);
1606  
1607 void
1608 sync(self)
1609 SV *self
1610 PREINIT:
1611 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 1 1
1612 CODE:
1613 1 ▶ if (pubsub_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_sync(h) != 0) 0 1 1
1614 0 croak("msync: %s", strerror(errno));
1615  
1616 void
1617 unlink(self_or_class, ...)
1618 SV *self_or_class
1619 CODE:
1620 const char *path;
1621 0 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int32")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int32")) { 0 0 0
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int32")) { 0 0 0
1622 0 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self_or_class)));
1623 0 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 0 0
1624 0 path = h->path;
1625 } else {
1626 0 ▶ if (items < 2) croak("Usage: Data::PubSub::Shared::Int32->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::PubSub::Shared::Int32->unlink($path)"); 0 0 0
1627 0 path = SvPV_nolen(ST(1));
1628 }
1629 0 ▶ if (!path) croak("cannot unlink anonymous or memfd pubsub");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd pubsub"); 0 0 0
1630 0 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
1631 0 croak("unlink(%s): %s", path, strerror(errno));
1632  
1633 IV
1634 eventfd(self)
1635 SV *self
1636 PREINIT:
1637 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1638 CODE:
1639 2 RETVAL = pubsub_eventfd_create(h);
1640 2 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 2 2
1641 OUTPUT:
1642 RETVAL
1643  
1644 void
1645 eventfd_set(self, fd)
1646 SV *self
1647 int fd
1648 PREINIT:
1649 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
1650 CODE:
1651 5 ▶ if (pubsub_eventfd_set(h, fd) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_eventfd_set(h, fd) < 0) 1 4 5
1652 1 croak("eventfd_set: %s", strerror(errno));
1653  
1654 IV
1655 fileno(self)
1656 SV *self
1657 PREINIT:
1658 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 5 5
1659 CODE:
1660 5 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 5 0 5
1661 OUTPUT:
1662 RETVAL
1663  
1664 SV *
1665 eventfd_consume(self)
1666 SV *self
1667 PREINIT:
1668 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 4 4
1669 CODE:
1670 4 int64_t v = pubsub_eventfd_consume(h);
1671 4 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 3 1 4
1672 OUTPUT:
1673 RETVAL
1674  
1675 void
1676 notify(self)
1677 SV *self
1678 PREINIT:
1679 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int32", self); 0 2 2
1680 CODE:
1681 2 pubsub_notify(h);
1682  
1683 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int32::Sub
1684  
1685 void
1686 DESTROY(self)
1687 SV *self
1688 CODE:
1689 12 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32::Sub")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32::Sub")) return; 12 0 12
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int32::Sub")) return; 0 12 12
1690 12 PubSubSub *sub = INT2PTR(PubSubSub*, SvIV(SvRV(self)));
1691 12 ▶ if (!sub) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) return; 0 12 12
1692 12 sv_setiv(SvRV(self), 0);
1693 12 ▶ if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata);
Branch: 1 branch
BranchTrueFalseTotal
if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata); 12 0 12
1694 12 pubsub_sub_destroy(sub);
1695  
1696 SV *
1697 poll(self)
1698 SV *self
1699 PREINIT:
1700 9 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 9 0 9
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 9 9
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 9 9
1701 int32_t value;
1702 CODE:
1703 9 int r = pubsub_int32_poll(sub, &value);
1704 9 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 8 1 9
1705 8 RETVAL = newSViv((IV)value);
1706 else
1707 1 RETVAL = &PL_sv_undef;
1708 OUTPUT:
1709 RETVAL
1710  
1711 void
1712 poll_multi(self, count)
1713 SV *self
1714 UV count
1715 PREINIT:
1716 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1717 int32_t value;
1718 PPCODE:
1719 7 ▶ for (UV i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < count; i++) { 7 0 7
1720 7 int r = pubsub_int32_poll(sub, &value);
1721 7 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 1 6 7
1722 6 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 6 6
1723 }
1724  
1725 SV *
1726 poll_wait(self, ...)
1727 SV *self
1728 PREINIT:
1729 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1730 1 double timeout = -1;
1731 int32_t value;
1732 CODE:
1733 1 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 1 0 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 1 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 1 0 1
1734 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1735 1 int r = pubsub_perl_int32_poll_wait(aTHX_ self, sub, &value, timeout);
1736 1 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 0 1 1
1737 0 RETVAL = newSViv((IV)value);
1738 else
1739 1 RETVAL = &PL_sv_undef;
1740 OUTPUT:
1741 RETVAL
1742  
1743 void
1744 drain(self, ...)
1745 SV *self
1746 PREINIT:
1747 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1748 int32_t value;
1749 uint32_t max_count;
1750 PPCODE:
1751 1 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 1 1
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
1752 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1753 9 ▶ while (max_count-- > 0 && pubsub_int32_poll(sub, &value))
Branch: 2 branches
BranchTrueFalseTotal
while (max_count-- > 0 && pubsub_int32_poll(sub, &value)) 9 0 9
while (max_count-- > 0 && pubsub_int32_poll(sub, &value)) 8 1 9
1754 8 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 8 8
1755  
1756 void
1757 poll_wait_multi(self, count, ...)
1758 SV *self
1759 UV count
1760 PREINIT:
1761 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1762 1 double timeout = -1;
1763 int32_t value;
1764 PPCODE:
1765 1 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 0 1 1
1766 1 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 1 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
1767 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1768 1 ▶ if (!pubsub_perl_int32_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_perl_int32_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0); 0 1 1
1769 1 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 1 1
1770 3 ▶ for (UV i = 1; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 1; i < count; i++) { 2 1 3
1771 2 ▶ if (!pubsub_int32_poll(sub, &value)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_int32_poll(sub, &value)) break; 0 2 2
1772 2 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 2 2
1773 }
1774  
1775 UV
1776 lag(self)
1777 SV *self
1778 PREINIT:
1779 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 3 3
1780 CODE:
1781 3 RETVAL = (UV)pubsub_lag(sub);
1782 OUTPUT:
1783 RETVAL
1784  
1785 UV
1786 overflow_count(self)
1787 SV *self
1788 PREINIT:
1789 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1790 CODE:
1791 1 ▶ RETVAL = (UV)sub->overflow_count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->overflow_count; 0 1 1
1792 OUTPUT:
1793 RETVAL
1794  
1795 UV
1796 write_pos(self)
1797 SV *self
1798 PREINIT:
1799 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
1800 CODE:
1801 0 ▶ RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED); 0 0 0
1802 OUTPUT:
1803 RETVAL
1804  
1805 bool
1806 has_overflow(self)
1807 SV *self
1808 PREINIT:
1809 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1810 CODE:
1811 1 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
1812 1 ▶ RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
1813 OUTPUT:
1814 RETVAL
1815  
1816 UV
1817 cursor(self, ...)
1818 SV *self
1819 PREINIT:
1820 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1821 CODE:
1822 1 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) {
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 1 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
1823 0 uint64_t new_cursor = (uint64_t)SvUV(ST(1));
1824 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
1825 0 sub->cursor = new_cursor;
1826 }
1827 1 ▶ RETVAL = (UV)sub->cursor;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->cursor; 0 1 1
1828 OUTPUT:
1829 RETVAL
1830  
1831 void
1832 reset(self)
1833 SV *self
1834 PREINIT:
1835 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1836 CODE:
1837 1 sub->cursor = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
1838  
1839 void
1840 reset_oldest(self)
1841 SV *self
1842 PREINIT:
1843 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1844 CODE:
1845 1 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
1846 1 ▶ sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0;
Branch: 1 branch
BranchTrueFalseTotal
sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0; 0 1 1
1847  
1848 UV
1849 poll_cb(self, cb)
1850 SV *self
1851 SV *cb
1852 PREINIT:
1853 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 1 1
1854 int32_t value;
1855 CODE:
1856 1 RETVAL = 0;
1857 /* Keep the backing handle alive across the callback: a callback that
1858 * drops self's last reference would free `sub` mid-loop (UAF). Guard
1859 * the referent (the blessed handle), not the RV container -- assigning
1860 * undef to self overwrites the container and frees the referent. */
1861 1 SV *psx_guard = SvRV(self);
1862 1 SvREFCNT_inc_simple_void_NN(psx_guard);
1863 1 SAVEFREESV(psx_guard);
1864 6 ▶ while (pubsub_int32_poll(sub, &value)) {
Branch: 1 branch
BranchTrueFalseTotal
while (pubsub_int32_poll(sub, &value)) { 5 1 6
1865 5 dSP;
1866 5 ENTER; SAVETMPS;
1867 5 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 5 5
1868 5 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 5 5
1869 5 PUTBACK;
1870 5 call_sv(cb, G_DISCARD);
1871 5 ▶ FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; LEAVE; 5 0 5
1872 /* call_sv ran arbitrary Perl: the callback may have DESTROYed or
1873 * replaced the subscriber. Re-extract before the next poll. */
1874 5 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 5 5
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 5 5
1875 5 RETVAL++;
1876 }
1877 OUTPUT:
1878 RETVAL
1879  
1880 void
1881 drain_notify(self, ...)
1882 SV *self
1883 PREINIT:
1884 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 2 2
1885 int32_t value;
1886 uint32_t max_count;
1887 PPCODE:
1888 2 pubsub_sub_eventfd_consume(sub);
1889 2 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 0 2
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 2 2
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 0 2
1890 2 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 2 2
REEXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 2 2
1891 7 ▶ while (max_count > 0 && pubsub_int32_poll(sub, &value)) {
Branch: 2 branches
BranchTrueFalseTotal
while (max_count > 0 && pubsub_int32_poll(sub, &value)) { 6 1 7
while (max_count > 0 && pubsub_int32_poll(sub, &value)) { 5 1 6
1892 5 max_count--;
1893 5 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 5 5
1894 }
1895 2 ▶ if (max_count == 0 && pubsub_lag(sub) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (max_count == 0 && pubsub_lag(sub) > 0) 1 1 2
if (max_count == 0 && pubsub_lag(sub) > 0) 1 0 1
1896 1 pubsub_notify_fd(sub->notify_fd);
1897  
1898 void
1899 eventfd_set(self, fd)
1900 SV *self
1901 int fd
1902 PREINIT:
1903 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
1904 CODE:
1905 0 sub->notify_fd = fd;
1906  
1907 IV
1908 fileno(self)
1909 SV *self
1910 PREINIT:
1911 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int32::Sub", self); 0 0 0
1912 CODE:
1913 0 ▶ RETVAL = sub->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = sub->notify_fd; 0 0 0
1914 OUTPUT:
1915 RETVAL
1916  
1917 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int16
1918  
1919 SV *
1920 new(class, path, capacity, ...)
1921 const char *class
1922 SV *path
1923 UV capacity
1924 PREINIT:
1925 char errbuf[PUBSUB_ERR_BUFLEN];
1926 CODE:
1927 12 ▶ mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600;
Branch: 4 branches
BranchTrueFalseTotal
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 12 12
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
mode_t fmode = (items > 3 && (SvGETMAGIC(ST(3)), SvOK(ST(3)))) ? (mode_t)SvUV(ST(3)) : 0600; 0 0 0
1928 13 ▶ 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 12 12
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; 1 11 12
1929 12 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 12 12
1930 12 PubSubHandle *h = pubsub_create(p, (uint32_t)capacity, PUBSUB_MODE_INT16, 0, fmode, errbuf);
1931 12 ▶ if (!h) croak("Data::PubSub::Shared::Int16->new: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int16->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 11 12
if (!h) croak("Data::PubSub::Shared::Int16->new: %s", errbuf[0] ? errbuf : "out of memory"); 1 0 1
1932 11 MAKE_OBJ(class, h);
1933 OUTPUT:
1934 RETVAL
1935  
1936 SV *
1937 new_memfd(class, name, capacity)
1938 const char *class
1939 const char *name
1940 UV capacity
1941 PREINIT:
1942 char errbuf[PUBSUB_ERR_BUFLEN];
1943 CODE:
1944 2 ▶ if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32");
Branch: 1 branch
BranchTrueFalseTotal
if (capacity > 0xFFFFFFFFU) croak("Data::PubSub::Shared->new: capacity exceeds 2^32"); 0 2 2
1945 2 PubSubHandle *h = pubsub_create_memfd(name, (uint32_t)capacity, PUBSUB_MODE_INT16, 0, errbuf);
1946 2 ▶ if (!h) croak("Data::PubSub::Shared::Int16->new_memfd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int16->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int16->new_memfd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
1947 2 MAKE_OBJ(class, h);
1948 OUTPUT:
1949 RETVAL
1950  
1951 SV *
1952 new_from_fd(class, fd)
1953 const char *class
1954 int fd
1955 PREINIT:
1956 char errbuf[PUBSUB_ERR_BUFLEN];
1957 CODE:
1958 2 PubSubHandle *h = pubsub_open_fd(fd, PUBSUB_MODE_INT16, errbuf);
1959 2 ▶ if (!h) croak("Data::PubSub::Shared::Int16->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory");
Branch: 2 branches
BranchTrueFalseTotal
if (!h) croak("Data::PubSub::Shared::Int16->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 2 2
if (!h) croak("Data::PubSub::Shared::Int16->new_from_fd: %s", errbuf[0] ? errbuf : "out of memory"); 0 0 0
1960 2 MAKE_OBJ(class, h);
1961 OUTPUT:
1962 RETVAL
1963  
1964 IV
1965 memfd(self)
1966 SV *self
1967 PREINIT:
1968 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
1969 CODE:
1970 2 ▶ RETVAL = h->backing_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->backing_fd; 2 0 2
1971 OUTPUT:
1972 RETVAL
1973  
1974 void
1975 DESTROY(self)
1976 SV *self
1977 CODE:
1978 15 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16")) return; 15 0 15
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16")) return; 0 15 15
1979 15 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self)));
1980 15 ▶ if (!h) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!h) return; 0 15 15
1981 15 sv_setiv(SvRV(self), 0);
1982 15 pubsub_destroy(h);
1983  
1984 bool
1985 publish(self, value)
1986 SV *self
1987 IV value
1988 PREINIT:
1989 49 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 49 0 49
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 49 49
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 49 49
1990 CODE:
1991 49 ▶ RETVAL = pubsub_int16_publish(h, (int16_t)value);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = pubsub_int16_publish(h, (int16_t)value); 49 0 49
1992 OUTPUT:
1993 RETVAL
1994  
1995 #ifdef PUBSUB_TEST_HOOKS
1996  
1997 void
1998 _publish_at(self, pos, value)
1999 SV *self
2000 UV pos
2001 IV value
2002 PREINIT:
2003 EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
2004 CODE:
2005 pubsub_int16_commit_at(h, (uint64_t)pos, (int16_t)value);
2006  
2007 UV
2008 _slot_seq(self, pos)
2009 SV *self
2010 UV pos
2011 PREINIT:
2012 EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
2013 CODE:
2014 RETVAL = (UV)((PubSubInt16Slot *)h->slots)[pos & h->cap_mask].sequence;
2015 OUTPUT:
2016 RETVAL
2017  
2018 #endif
2019  
2020 UV
2021 publish_multi(self, ...)
2022 SV *self
2023 PREINIT:
2024 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
2025 CODE:
2026 2 uint32_t count = items - 1;
2027 2 ▶ if (count == 0) { RETVAL = 0; }
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) { RETVAL = 0; } 0 2 2
2028 else {
2029 2 ▶ if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count);
Branch: 1 branch
BranchTrueFalseTotal
if (count > 8192) croak("publish_multi: too many values (%u > 8192)", count); 0 2 2
2030 2 int16_t *vals = (int16_t *)alloca(count * sizeof(int16_t));
2031 10 ▶ for (uint32_t i = 0; i < count; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (uint32_t i = 0; i < count; i++) 8 2 10
2032 8 vals[i] = (int16_t)SvIV(ST(i + 1));
2033 2 ▶ REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
REEXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
2034 2 RETVAL = pubsub_int16_publish_multi(h, vals, count);
2035 }
2036 OUTPUT:
2037 RETVAL
2038  
2039 void
2040 publish_notify(self, value)
2041 SV *self
2042 IV value
2043 PREINIT:
2044 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
2045 CODE:
2046 1 pubsub_int16_publish(h, (int16_t)value);
2047 1 pubsub_notify(h);
2048  
2049 SV *
2050 subscribe(self)
2051 SV *self
2052 PREINIT:
2053 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
2054 CODE:
2055 5 PubSubSub *sub = pubsub_subscribe(h, 0);
2056 5 ▶ if (!sub) croak("subscribe: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe: out of memory"); 0 5 5
2057 5 sub->userdata = (void *)newSVsv(self);
2058 5 MAKE_OBJ("Data::PubSub::Shared::Int16::Sub", sub);
2059 OUTPUT:
2060 RETVAL
2061  
2062 SV *
2063 subscribe_all(self)
2064 SV *self
2065 PREINIT:
2066 7 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 7 0 7
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 7 7
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 7 7
2067 CODE:
2068 7 PubSubSub *sub = pubsub_subscribe(h, 1);
2069 7 ▶ if (!sub) croak("subscribe_all: out of memory");
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) croak("subscribe_all: out of memory"); 0 7 7
2070 7 sub->userdata = (void *)newSVsv(self);
2071 7 MAKE_OBJ("Data::PubSub::Shared::Int16::Sub", sub);
2072 OUTPUT:
2073 RETVAL
2074  
2075 UV
2076 capacity(self)
2077 SV *self
2078 PREINIT:
2079 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
2080 CODE:
2081 1 ▶ RETVAL = h->capacity;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->capacity; 1 0 1
2082 OUTPUT:
2083 RETVAL
2084  
2085 UV
2086 write_pos(self)
2087 SV *self
2088 PREINIT:
2089 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 4 4
2090 CODE:
2091 4 ▶ RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&h->hdr->write_pos, __ATOMIC_RELAXED); 4 0 4
2092 OUTPUT:
2093 RETVAL
2094  
2095 SV *
2096 path(self)
2097 SV *self
2098 PREINIT:
2099 0 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
2100 CODE:
2101 0 ▶ RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->path ? newSVpv(h->path, 0) : &PL_sv_undef; 0 0 0
2102 OUTPUT:
2103 RETVAL
2104  
2105 SV *
2106 stats(self)
2107 SV *self
2108 PREINIT:
2109 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
2110 CODE:
2111 2 HV *hv = newHV();
2112 2 PubSubHeader *hdr = h->hdr;
2113 2 hv_store(hv, "capacity", 8, newSVuv(h->capacity), 0);
2114 2 hv_store(hv, "mmap_size", 9, newSVuv((UV)h->mmap_size), 0);
2115 2 hv_store(hv, "write_pos", 9,
2116 newSVuv((UV)__atomic_load_n(&hdr->write_pos, __ATOMIC_RELAXED)), 0);
2117 2 hv_store(hv, "publish_ok", 10,
2118 newSVuv((UV)__atomic_load_n(&hdr->stat_publish_ok, __ATOMIC_RELAXED)), 0);
2119 2 hv_store(hv, "recoveries", 10,
2120 newSVuv(__atomic_load_n(&hdr->stat_recoveries, __ATOMIC_RELAXED)), 0);
2121 2 hv_store(hv, "sub_waiters", 11,
2122 newSVuv(__atomic_load_n(&hdr->sub_waiters, __ATOMIC_RELAXED)), 0);
2123 2 RETVAL = newRV_noinc((SV *)hv);
2124 OUTPUT:
2125 RETVAL
2126  
2127 void
2128 clear(self)
2129 SV *self
2130 PREINIT:
2131 1 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 1 0 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 1 1
2132 CODE:
2133 1 pubsub_clear(h);
2134  
2135 void
2136 sync(self)
2137 SV *self
2138 PREINIT:
2139 0 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 0 0
2140 CODE:
2141 0 ▶ if (pubsub_sync(h) != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_sync(h) != 0) 0 0 0
2142 0 croak("msync: %s", strerror(errno));
2143  
2144 void
2145 unlink(self_or_class, ...)
2146 SV *self_or_class
2147 CODE:
2148 const char *path;
2149 0 ▶ if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int16")) {
Branch: 2 branches
BranchTrueFalseTotal
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int16")) { 0 0 0
if (sv_isobject(self_or_class) && sv_derived_from(self_or_class, "Data::PubSub::Shared::Int16")) { 0 0 0
2150 0 PubSubHandle *h = INT2PTR(PubSubHandle*, SvIV(SvRV(self_or_class)));
2151 0 ▶ if (!h) croak("Attempted to use a destroyed object");
Branch: 1 branch
BranchTrueFalseTotal
if (!h) croak("Attempted to use a destroyed object"); 0 0 0
2152 0 path = h->path;
2153 } else {
2154 0 ▶ if (items < 2) croak("Usage: Data::PubSub::Shared::Int16->unlink($path)");
Branch: 1 branch
BranchTrueFalseTotal
if (items < 2) croak("Usage: Data::PubSub::Shared::Int16->unlink($path)"); 0 0 0
2155 0 path = SvPV_nolen(ST(1));
2156 }
2157 0 ▶ if (!path) croak("cannot unlink anonymous or memfd pubsub");
Branch: 1 branch
BranchTrueFalseTotal
if (!path) croak("cannot unlink anonymous or memfd pubsub"); 0 0 0
2158 0 ▶ if (unlink(path) != 0 && errno != ENOENT)
Branch: 2 branches
BranchTrueFalseTotal
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
if (unlink(path) != 0 && errno != ENOENT) 0 0 0
2159 0 croak("unlink(%s): %s", path, strerror(errno));
2160  
2161 IV
2162 eventfd(self)
2163 SV *self
2164 PREINIT:
2165 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
2166 CODE:
2167 2 RETVAL = pubsub_eventfd_create(h);
2168 2 ▶ if (RETVAL < 0) croak("eventfd: %s", strerror(errno));
Branch: 1 branch
BranchTrueFalseTotal
if (RETVAL < 0) croak("eventfd: %s", strerror(errno)); 0 2 2
2169 OUTPUT:
2170 RETVAL
2171  
2172 void
2173 eventfd_set(self, fd)
2174 SV *self
2175 int fd
2176 PREINIT:
2177 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
2178 CODE:
2179 5 ▶ if (pubsub_eventfd_set(h, fd) < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (pubsub_eventfd_set(h, fd) < 0) 1 4 5
2180 1 croak("eventfd_set: %s", strerror(errno));
2181  
2182 IV
2183 fileno(self)
2184 SV *self
2185 PREINIT:
2186 5 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 5 0 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 5 5
2187 CODE:
2188 5 ▶ RETVAL = h->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = h->notify_fd; 5 0 5
2189 OUTPUT:
2190 RETVAL
2191  
2192 SV *
2193 eventfd_consume(self)
2194 SV *self
2195 PREINIT:
2196 4 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 4 0 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 4 4
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 4 4
2197 CODE:
2198 4 int64_t v = pubsub_eventfd_consume(h);
2199 4 ▶ RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (v >= 0) ? newSViv((IV)v) : &PL_sv_undef; 3 1 4
2200 OUTPUT:
2201 RETVAL
2202  
2203 void
2204 notify(self)
2205 SV *self
2206 PREINIT:
2207 2 ▶ EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 2 0 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
EXTRACT_HANDLE("Data::PubSub::Shared::Int16", self); 0 2 2
2208 CODE:
2209 2 pubsub_notify(h);
2210  
2211 MODULE = Data::PubSub::Shared PACKAGE = Data::PubSub::Shared::Int16::Sub
2212  
2213 void
2214 DESTROY(self)
2215 SV *self
2216 CODE:
2217 12 ▶ if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16::Sub")) return;
Branch: 2 branches
BranchTrueFalseTotal
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16::Sub")) return; 12 0 12
if (!sv_isobject(self) || !sv_derived_from(self, "Data::PubSub::Shared::Int16::Sub")) return; 0 12 12
2218 12 PubSubSub *sub = INT2PTR(PubSubSub*, SvIV(SvRV(self)));
2219 12 ▶ if (!sub) return;
Branch: 1 branch
BranchTrueFalseTotal
if (!sub) return; 0 12 12
2220 12 sv_setiv(SvRV(self), 0);
2221 12 ▶ if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata);
Branch: 1 branch
BranchTrueFalseTotal
if (sub->userdata) SvREFCNT_dec((SV *)sub->userdata); 12 0 12
2222 12 pubsub_sub_destroy(sub);
2223  
2224 SV *
2225 poll(self)
2226 SV *self
2227 PREINIT:
2228 9 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 9 0 9
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 9 9
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 9 9
2229 int16_t value;
2230 CODE:
2231 9 int r = pubsub_int16_poll(sub, &value);
2232 9 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 8 1 9
2233 8 RETVAL = newSViv((IV)value);
2234 else
2235 1 RETVAL = &PL_sv_undef;
2236 OUTPUT:
2237 RETVAL
2238  
2239 void
2240 poll_multi(self, count)
2241 SV *self
2242 UV count
2243 PREINIT:
2244 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2245 int16_t value;
2246 PPCODE:
2247 7 ▶ for (UV i = 0; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 0; i < count; i++) { 7 0 7
2248 7 int r = pubsub_int16_poll(sub, &value);
2249 7 ▶ if (r != 1) break;
Branch: 1 branch
BranchTrueFalseTotal
if (r != 1) break; 1 6 7
2250 6 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 6 6
2251 }
2252  
2253 SV *
2254 poll_wait(self, ...)
2255 SV *self
2256 PREINIT:
2257 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2258 1 double timeout = -1;
2259 int16_t value;
2260 CODE:
2261 1 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 1 0 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 1 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) timeout = SvNV(ST(1)); 1 0 1
2262 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2263 1 int r = pubsub_perl_int16_poll_wait(aTHX_ self, sub, &value, timeout);
2264 1 ▶ if (r == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (r == 1) 0 1 1
2265 0 RETVAL = newSViv((IV)value);
2266 else
2267 1 RETVAL = &PL_sv_undef;
2268 OUTPUT:
2269 RETVAL
2270  
2271 void
2272 drain(self, ...)
2273 SV *self
2274 PREINIT:
2275 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2276 int16_t value;
2277 uint32_t max_count;
2278 PPCODE:
2279 1 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 1 1
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
2280 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2281 9 ▶ while (max_count-- > 0 && pubsub_int16_poll(sub, &value))
Branch: 2 branches
BranchTrueFalseTotal
while (max_count-- > 0 && pubsub_int16_poll(sub, &value)) 9 0 9
while (max_count-- > 0 && pubsub_int16_poll(sub, &value)) 8 1 9
2282 8 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 8 8
2283  
2284 void
2285 poll_wait_multi(self, count, ...)
2286 SV *self
2287 UV count
2288 PREINIT:
2289 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2290 1 double timeout = -1;
2291 int16_t value;
2292 PPCODE:
2293 1 ▶ if (count == 0) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (count == 0) XSRETURN(0); 0 1 1
2294 1 ▶ if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2));
Branch: 4 branches
BranchTrueFalseTotal
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 1 1
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 0 0 0
if (items > 2 && (SvGETMAGIC(ST(2)), SvOK(ST(2)))) timeout = SvNV(ST(2)); 1 0 1
2295 1 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2296 1 ▶ if (!pubsub_perl_int16_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0);
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_perl_int16_poll_wait(aTHX_ self, sub, &value, timeout)) XSRETURN(0); 0 1 1
2297 1 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 1 1
2298 3 ▶ for (UV i = 1; i < count; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (UV i = 1; i < count; i++) { 2 1 3
2299 2 ▶ if (!pubsub_int16_poll(sub, &value)) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!pubsub_int16_poll(sub, &value)) break; 0 2 2
2300 2 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 2 2
2301 }
2302  
2303 UV
2304 lag(self)
2305 SV *self
2306 PREINIT:
2307 3 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 3 0 3
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 3 3
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 3 3
2308 CODE:
2309 3 RETVAL = (UV)pubsub_lag(sub);
2310 OUTPUT:
2311 RETVAL
2312  
2313 UV
2314 overflow_count(self)
2315 SV *self
2316 PREINIT:
2317 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2318 CODE:
2319 1 ▶ RETVAL = (UV)sub->overflow_count;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->overflow_count; 1 0 1
2320 OUTPUT:
2321 RETVAL
2322  
2323 UV
2324 write_pos(self)
2325 SV *self
2326 PREINIT:
2327 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
2328 CODE:
2329 0 ▶ RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)__atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED); 0 0 0
2330 OUTPUT:
2331 RETVAL
2332  
2333 bool
2334 has_overflow(self)
2335 SV *self
2336 PREINIT:
2337 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2338 CODE:
2339 1 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_RELAXED);
2340 1 ▶ RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity);
Branch: 3 branches
BranchTrueFalseTotal
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
RETVAL = (sub->cursor < wp && wp - sub->cursor > sub->capacity); 1 0 1
2341 OUTPUT:
2342 RETVAL
2343  
2344 UV
2345 cursor(self, ...)
2346 SV *self
2347 PREINIT:
2348 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2349 CODE:
2350 1 ▶ if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) {
Branch: 4 branches
BranchTrueFalseTotal
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 1 1
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
if (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) { 0 0 0
2351 0 uint64_t new_cursor = (uint64_t)SvUV(ST(1));
2352 0 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
2353 0 sub->cursor = new_cursor;
2354 }
2355 1 ▶ RETVAL = (UV)sub->cursor;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = (UV)sub->cursor; 1 0 1
2356 OUTPUT:
2357 RETVAL
2358  
2359 void
2360 reset(self)
2361 SV *self
2362 PREINIT:
2363 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2364 CODE:
2365 1 sub->cursor = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
2366  
2367 void
2368 reset_oldest(self)
2369 SV *self
2370 PREINIT:
2371 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2372 CODE:
2373 1 uint64_t wp = __atomic_load_n(&sub->hdr->write_pos, __ATOMIC_ACQUIRE);
2374 1 ▶ sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0;
Branch: 1 branch
BranchTrueFalseTotal
sub->cursor = (wp > sub->capacity) ? wp - sub->capacity : 0; 0 1 1
2375  
2376 UV
2377 poll_cb(self, cb)
2378 SV *self
2379 SV *cb
2380 PREINIT:
2381 1 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 1 0 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 1 1
2382 int16_t value;
2383 CODE:
2384 1 RETVAL = 0;
2385 /* Keep the backing handle alive across the callback: a callback that
2386 * drops self's last reference would free `sub` mid-loop (UAF). Guard
2387 * the referent (the blessed handle), not the RV container -- assigning
2388 * undef to self overwrites the container and frees the referent. */
2389 1 SV *psx_guard = SvRV(self);
2390 1 SvREFCNT_inc_simple_void_NN(psx_guard);
2391 1 SAVEFREESV(psx_guard);
2392 6 ▶ while (pubsub_int16_poll(sub, &value)) {
Branch: 1 branch
BranchTrueFalseTotal
while (pubsub_int16_poll(sub, &value)) { 5 1 6
2393 5 dSP;
2394 5 ENTER; SAVETMPS;
2395 5 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 5 5
2396 5 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 5 5
2397 5 PUTBACK;
2398 5 call_sv(cb, G_DISCARD);
2399 5 ▶ FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
FREETMPS; LEAVE; 5 0 5
2400 /* call_sv ran arbitrary Perl: the callback may have DESTROYed or
2401 * replaced the subscriber. Re-extract before the next poll. */
2402 5 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 5 5
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 5 5
2403 5 RETVAL++;
2404 }
2405 OUTPUT:
2406 RETVAL
2407  
2408 void
2409 drain_notify(self, ...)
2410 SV *self
2411 PREINIT:
2412 2 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 2 0 2
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 2 2
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 2 2
2413 int16_t value;
2414 uint32_t max_count;
2415 PPCODE:
2416 2 pubsub_sub_eventfd_consume(sub);
2417 2 ▶ max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX;
Branch: 4 branches
BranchTrueFalseTotal
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 0 2
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 2 2
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 0 0 0
max_count = (items > 1 && (SvGETMAGIC(ST(1)), SvOK(ST(1)))) ? (uint32_t)SvUV(ST(1)) : UINT32_MAX; 2 0 2
2418 2 ▶ REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 2 branches
BranchTrueFalseTotal
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 2 2
REEXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 2 2
2419 7 ▶ while (max_count > 0 && pubsub_int16_poll(sub, &value)) {
Branch: 2 branches
BranchTrueFalseTotal
while (max_count > 0 && pubsub_int16_poll(sub, &value)) { 6 1 7
while (max_count > 0 && pubsub_int16_poll(sub, &value)) { 5 1 6
2420 5 max_count--;
2421 5 ▶ mXPUSHi((IV)value);
Branch: 1 branch
BranchTrueFalseTotal
mXPUSHi((IV)value); 0 5 5
2422 }
2423 2 ▶ if (max_count == 0 && pubsub_lag(sub) > 0)
Branch: 2 branches
BranchTrueFalseTotal
if (max_count == 0 && pubsub_lag(sub) > 0) 1 1 2
if (max_count == 0 && pubsub_lag(sub) > 0) 1 0 1
2424 1 pubsub_notify_fd(sub->notify_fd);
2425  
2426 void
2427 eventfd_set(self, fd)
2428 SV *self
2429 int fd
2430 PREINIT:
2431 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
2432 CODE:
2433 0 sub->notify_fd = fd;
2434  
2435 IV
2436 fileno(self)
2437 SV *self
2438 PREINIT:
2439 0 ▶ EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self);
Branch: 3 branches
BranchTrueFalseTotal
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
EXTRACT_SUB("Data::PubSub::Shared::Int16::Sub", self); 0 0 0
2440 CODE:
2441 0 ▶ RETVAL = sub->notify_fd;
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = sub->notify_fd; 0 0 0
2442 OUTPUT:
2443 RETVAL
« blib/lib/Data/PubSub/Shared.pm ↑ Summary pubsub.h »