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.10 by root, Fri Jul 17 03:32:29 2009 UTC vs.
Revision 1.11 by root, Fri Jul 17 21:02:18 2009 UTC

31 void (*c_cb)(pTHX_ void *c_arg, int value); 31 void (*c_cb)(pTHX_ void *c_arg, int value);
32 void *c_arg; 32 void *c_arg;
33 SV *fh_r, *fh_w; 33 SV *fh_r, *fh_w;
34 SV *value; 34 SV *value;
35 int signum; 35 int signum;
36 int autodrain;
36 volatile int blocked; 37 volatile int blocked;
37 38
38 s_epipe ep; 39 s_epipe ep;
39 int fd_wlen; 40 int fd_wlen;
40 atomic_t fd_enable; 41 atomic_t fd_enable;
75 76
76 *async->valuep = 0; 77 *async->valuep = 0;
77 async->pending = 0; 78 async->pending = 0;
78 79
79 /* drain pipe */ 80 /* drain pipe */
80 if (async->fd_enable && async->ep.len) 81 if (async->fd_enable && async->ep.len && async->autodrain)
81 s_epipe_drain (&async->ep); 82 s_epipe_drain (&async->ep);
82 83
83 if (async->c_cb) 84 if (async->c_cb)
84 { 85 {
85 dTHX; 86 dTHX;
233 SvIOK_only (async->value); /* just to be sure */ 234 SvIOK_only (async->value); /* just to be sure */
234 SvREADONLY_on (async->value); 235 SvREADONLY_on (async->value);
235 236
236 async->valuep = &(SvIVX (async->value)); 237 async->valuep = &(SvIVX (async->value));
237 238
239 async->autodrain = 1;
238 async->cb = cv; 240 async->cb = cv;
239 async->c_cb = c_cb; 241 async->c_cb = c_cb;
240 async->c_arg = c_arg; 242 async->c_arg = c_arg;
241 async->signum = SvOK (signl) ? s_signum_croak (signl) : 0; 243 async->signum = SvOK (signl) ? s_signum_croak (signl) : 0;
242 244
327 329
328 RETVAL = async->ep.fd [0]; 330 RETVAL = async->ep.fd [0];
329 OUTPUT: 331 OUTPUT:
330 RETVAL 332 RETVAL
331 333
334int
335pipe_autodrain (async_t *async, int enable = -1)
336 CODE:
337 RETVAL = async->autodrain;
338 if (enable >= 0)
339 async->autodrain = enable;
340 OUTPUT:
341 RETVAL
332 342
333void 343void
334post_fork (async_t *async) 344post_fork (async_t *async)
335 CODE: 345 CODE:
336 if (async->ep.len) 346 if (async->ep.len)
390 SvREFCNT_dec (async->value); 400 SvREFCNT_dec (async->value);
391 401
392 Safefree (async); 402 Safefree (async);
393} 403}
394 404
405MODULE = Async::Interrupt PACKAGE = Async::Interrupt::EventPipe PREFIX = s_epipe_
406
407void
408new (const char *klass)
409 PPCODE:
410{
411 s_epipe *epp;
412 SV *self;
413
414 Newz (0, epp, 1, s_epipe);
415 XPUSHs (sv_setref_iv (sv_newmortal (), klass, PTR2IV (epp)));
416
417 if (s_epipe_new (epp) < 0)
418 croak ("Async::Interrupt::EventPipe: unable to create new event pipe");
419}
420
421void
422filenos (s_epipe *epp)
423 PPCODE:
424 EXTEND (SP, 2);
425 PUSHs (sv_2mortal (newSViv (epp->fd [0])));
426 PUSHs (sv_2mortal (newSViv (epp->fd [1])));
427
428int
429fileno (s_epipe *epp)
430 ALIAS:
431 fileno = 0
432 fileno_r = 0
433 fileno_w = 1
434 CODE:
435 RETVAL = epp->fd [ix];
436 OUTPUT:
437 RETVAL
438
439int
440type (s_epipe *epp)
441 CODE:
442 RETVAL = epp->len;
443 OUTPUT:
444 RETVAL
445
446void
447s_epipe_signal (s_epipe *epp)
448
449void
450s_epipe_drain (s_epipe *epp)
451
452void
453DESTROY (s_epipe *epp)
454 CODE:
455 s_epipe_destroy (epp);
456

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines