ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Async-Interrupt/Interrupt.xs
(Generate patch)

Comparing Async-Interrupt/Interrupt.xs (file contents):
Revision 1.3 by root, Thu Jul 2 15:17:57 2009 UTC vs.
Revision 1.4 by root, Thu Jul 2 16:12:40 2009 UTC

165 else 165 else
166 old_sighandler (signum); 166 old_sighandler (signum);
167} 167}
168#endif 168#endif
169 169
170static void
171scope_block_cb (pTHX_ void *async_sv)
172{
173 struct async *async = INT2PTR (struct async *, SvIVX ((SV *)async_sv));
174
175 --async->blocked;
176 if (async->pending && !async->blocked)
177 handle_async (async);
178
179 SvREFCNT_dec (async_sv);
180}
170 181
171MODULE = Async::Interrupt PACKAGE = Async::Interrupt 182MODULE = Async::Interrupt PACKAGE = Async::Interrupt
172 183
173BOOT: 184BOOT:
174 old_sighandler = PL_sighandlerp; 185 old_sighandler = PL_sighandlerp;
175 PL_sighandlerp = async_sighandler; 186 PL_sighandlerp = async_sighandler;
176 sig_pending = &PL_sig_pending; 187 sig_pending = &PL_sig_pending;
177 psig_pend = PL_psig_pend; 188 psig_pend = PL_psig_pend;
178 asyncs = newAV (); 189 asyncs = newAV ();
190 CvNODEBUG_on (get_cv ("Async::Interrupt::scope_block", 0)); /* otherwise calling scope can be the debugger */
179 191
180PROTOTYPES: DISABLE 192PROTOTYPES: DISABLE
181 193
182SV * 194SV *
183_alloc (SV *cb, void *c_cb, void *c_arg, SV *fh_r, SV *fh_w) 195_alloc (SV *cb, void *c_cb, void *c_arg, SV *fh_r, SV *fh_w)
228unblock (SV *self) 240unblock (SV *self)
229 CODE: 241 CODE:
230{ 242{
231 struct async *async = INT2PTR (struct async *, SvIVX (SvRV (self))); 243 struct async *async = INT2PTR (struct async *, SvIVX (SvRV (self)));
232 --async->blocked; 244 --async->blocked;
233
234 if (async->pending && !async->blocked) 245 if (async->pending && !async->blocked)
235 handle_async (async); 246 handle_async (async);
247}
248
249void
250scope_block (SV *self)
251 CODE:
252{
253 SV *async_sv = SvRV (self);
254 struct async *async = INT2PTR (struct async *, SvIVX (async_sv));
255 ++async->blocked;
256
257 LEAVE; /* unfortunately, perl sandwiches XS calls into ENTER/LEAVE */
258 SAVEDESTRUCTOR_X (scope_block_cb, (void *)SvREFCNT_inc (async_sv));
259 ENTER; /* unfortunately, perl sandwiches XS calls into ENTER/LEAVE */
236} 260}
237 261
238void 262void
239DESTROY (SV *self) 263DESTROY (SV *self)
240 CODE: 264 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines