… | |
… | |
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 | |
|
|
334 | int |
|
|
335 | pipe_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 | |
333 | void |
343 | void |
334 | post_fork (async_t *async) |
344 | post_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 | |
|
|
405 | MODULE = Async::Interrupt PACKAGE = Async::Interrupt::EventPipe PREFIX = s_epipe_ |
|
|
406 | |
|
|
407 | void |
|
|
408 | new (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 | |
|
|
421 | void |
|
|
422 | filenos (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 | |
|
|
428 | int |
|
|
429 | fileno (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 | |
|
|
439 | int |
|
|
440 | type (s_epipe *epp) |
|
|
441 | CODE: |
|
|
442 | RETVAL = epp->len; |
|
|
443 | OUTPUT: |
|
|
444 | RETVAL |
|
|
445 | |
|
|
446 | void |
|
|
447 | s_epipe_signal (s_epipe *epp) |
|
|
448 | |
|
|
449 | void |
|
|
450 | s_epipe_drain (s_epipe *epp) |
|
|
451 | |
|
|
452 | void |
|
|
453 | DESTROY (s_epipe *epp) |
|
|
454 | CODE: |
|
|
455 | s_epipe_destroy (epp); |
|
|
456 | |