xs/dbil.xs

filter: Statementstmt 89.6% 26 / 29 Branchbran 37.5% 6 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 71.1% 32 / 45 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« xs/sendfile.xs ↑ Summary include/punk/punk_sse.h »
1 MODULE = Punk PACKAGE = Punk::Model::DBIx::Loop
2  
3 PROTOTYPES: DISABLE
4  
5 # The async model backend, in C (punk_dbil.h). The same six-method contract
6 # as Punk::Model::DBI, but every method returns a Punk::Future: the statement
7 # runs on DBIx::Loop over the worker's own loop, reached through its C ABI,
8 # and one C continuation settles the future when the rows land.
9 # Punk::Model::DBIx::Loop.pm is the documentation.
10  
11 SV *
12 new(class, ...)
13 SV *class
14 CODE:
15 16 RETVAL = pdbi_build_self(aTHX_ class, &ST(0), items, PDL_CLS);
16 OUTPUT:
17 RETVAL
18  
19 # The per-worker DBIx::Loop connection for this backend's dsn, built on the
20 # first statement and shared with every other backend on the same one.
21 SV *
22 db(self)
23 SV *self
24 CODE:
25 {
26 10 SV *v = pdbi_get(aTHX_ pdl_handle(aTHX_ self), "db");
27 10 ▶ RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */ 10 0 10
28 }
29 OUTPUT:
30 RETVAL
31  
32 # The parent DBI handle (DBIx::Loop's own), for parity with the DBI
33 # backend's reach-through; statements do NOT run on it.
34 SV *
35 dbh(self)
36 SV *self
37 CODE:
38 {
39 7 SV *v = pdbi_get(aTHX_ pdl_handle(aTHX_ self), "dbh");
40 6 ▶ RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */ 6 0 6
41 }
42 OUTPUT:
43 RETVAL
44  
45 # The DBIx::Loop loop adapter this connection runs on.
46 SV *
47 adapter(self)
48 SV *self
49 CODE:
50 {
51 1 SV *v = pdbi_get(aTHX_ pdl_handle(aTHX_ self), "adapter");
52 1 ▶ RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = v ? newSVsv(v) : newSV(0); /* # uncoverable condition right count:1 class:ignore_covered_err */ 1 0 1
53 }
54 OUTPUT:
55 RETVAL
56  
57 IV
58 # uncoverable statement
59 # uncoverable subroutine
60 _returning(self)
61 SV *self
62 CODE:
63 {
64 0 SV *r = pdbi_get(aTHX_ pdl_handle(aTHX_ self), "returning"); /* # uncoverable statement */
65 0 ▶ # uncoverable statement
Branch: 2 branches
BranchTrueFalseTotal
# uncoverable statement 0 0 0
# uncoverable statement 0 0 0
66 # uncoverable condition left count:1
67 # uncoverable condition right count:1
68 # uncoverable condition left count:2
69 # uncoverable condition right count:2
70 RETVAL = r ? SvIV(r) : 0;
71 }
72 OUTPUT:
73 RETVAL
74  
75 # Is DBIx::Loop's C ABI resolvable and new enough? The guard test's probe.
76 IV
77 _abi_ok(class)
78 SV *class
79 CODE:
80 PERL_UNUSED_VAR(class);
81 2 ▶ RETVAL = punk_dbil_try(aTHX) ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */
Branch: 1 branch
BranchTrueFalseTotal
RETVAL = punk_dbil_try(aTHX) ? 1 : 0; /* # uncoverable condition left count:1 class:ignore_covered_err */ 0 2 2
82 OUTPUT:
83 RETVAL
84  
85 # ---- the contract: everything returns a Punk::Future ------------------------
86  
87 SV *
88 get(self, ...)
89 SV *self
90 CODE:
91 15 RETVAL = pdl_get(aTHX_ self, &ST(0), items);
92 OUTPUT:
93 RETVAL
94  
95 SV *
96 search(self, filter = &PL_sv_undef, opts = &PL_sv_undef)
97 SV *self
98 SV *filter
99 SV *opts
100 CODE:
101 136 RETVAL = pdl_search(aTHX_ self, filter, opts);
102 OUTPUT:
103 RETVAL
104  
105 SV *
106 count(self, filter = &PL_sv_undef)
107 SV *self
108 SV *filter
109 CODE:
110 18 RETVAL = pdl_count(aTHX_ self, filter);
111 OUTPUT:
112 RETVAL
113  
114 SV *
115 # uncoverable statement
116 # uncoverable subroutine
117 all(self)
118 SV *self
119 CODE:
120 0 RETVAL = pdl_search(aTHX_ self, &PL_sv_undef, &PL_sv_undef); /* # uncoverable statement */
121 OUTPUT:
122 RETVAL
123  
124 SV *
125 create(self, data)
126 SV *self
127 SV *data
128 CODE:
129 28 RETVAL = pdl_create(aTHX_ self, data);
130 OUTPUT:
131 RETVAL
132  
133 SV *
134 update(self, data)
135 SV *self
136 SV *data
137 CODE:
138 5 RETVAL = pdl_update(aTHX_ self, data);
139 OUTPUT:
140 RETVAL
141  
142 SV *
143 delete(self, ...)
144 SV *self
145 CODE:
146 4 RETVAL = pdl_delete(aTHX_ self, &ST(0), items);
147 OUTPUT:
148 RETVAL
149  
150 # future($dbil_future): bridge a raw DBIx::Loop::Future - from a custom
151 # query on $backend->db - into a Punk::Future carrying the same values.
152 SV *
153 future(self, f)
154 SV *self
155 SV *f
156 CODE:
157 2 RETVAL = pdl_wrap(aTHX_ self, f);
158 OUTPUT:
159 RETVAL
160  
161 # await($future): resolve one of this backend's futures outside a worker, by
162 # pumping the adapter's own loop. Inside a worker $c->await already does this
163 # against the worker's loop. Returns the settled values (croaks on failure),
164 # exactly as Punk::Future->get does.
165 void
166 await(self, f)
167 SV *self
168 SV *f
169 PPCODE:
170 {
171 8 pdl_await(aTHX_ self, f);
172 /* The loop has just run arbitrary callbacks, and any of them may
173 * have grown the value stack - which moves it. SP is where the stack
174 * WAS when this XSUB was entered, so it is worked out again from the
175 * base: the slot below this call's first argument, which is where
176 * PPCODE left it and where get's values have to land. */
177 8 SP = PL_stack_base + ax - 1;
178 8 ▶ PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
PUSHMARK(SP); 0 8 8
179 8 ▶ EXTEND(SP, 1);
Branch: 1 branch
BranchTrueFalseTotal
EXTEND(SP, 1); 0 8 8
180 8 PUSHs(f);
181 8 PUTBACK;
182 8 call_method("get", GIMME_V);
183 8 SPAGAIN;
184 8 return; /* the values get() left on the stack */
185 }
186  
187 # ---- the opaque keyset token (the SHARED codec - see punk_dbi.h) -----------
188  
189 SV *
190 _encode_token(self, val)
191 SV *self
192 SV *val
193 CODE:
194 PERL_UNUSED_VAR(self);
195 1 RETVAL = pdbi_encode_token(aTHX_ val);
196 OUTPUT:
197 RETVAL
198  
199 SV *
200 _decode_token(self, tok)
201 SV *self
202 SV *tok
203 CODE:
204 PERL_UNUSED_VAR(self);
205 1 RETVAL = pdbi_decode_token(aTHX_ tok, PDL_CLS);
206 OUTPUT:
207 RETVAL
« xs/sendfile.xs ↑ Summary include/punk/punk_sse.h »