--- cvsroot/EV/EV.xs 2007/10/31 13:57:34 1.20 +++ cvsroot/EV/EV.xs 2007/10/31 20:19:20 1.25 @@ -5,6 +5,7 @@ /*#include */ #define TIMEOUT_NONE HUGE_VAL +#define HAVE_EPOLL 1 #define EV_PROTOTYPES 1 #include "EV/EVAPI.h" @@ -23,7 +24,9 @@ *stash_periodic, *stash_signal, *stash_idle, - *stash_check; + *stash_prepare, + *stash_check, + *stash_child; static int sv_signum (SV *sig) @@ -103,7 +106,7 @@ { dSP; I32 mark = SP - PL_stack_base; - SV *sv_self, *sv_events; + SV *sv_self, *sv_events, *sv_status = 0; static SV *sv_events_cache; sv_self = newRV_inc (w->self); /* w->self MUST be blessed by now */ @@ -120,11 +123,16 @@ EXTEND (SP, 2); PUSHs (sv_self); PUSHs (sv_events); + + if (revents & EV_CHILD) + XPUSHs (sv_status = newSViv (((struct ev_child *)w)->status)); + PUTBACK; call_sv (w->cb_sv, G_DISCARD | G_VOID | G_EVAL); SP = PL_stack_base + mark; PUTBACK; SvREFCNT_dec (sv_self); + SvREFCNT_dec (sv_status); if (sv_events_cache) SvREFCNT_dec (sv_events); @@ -202,6 +210,8 @@ MODULE = EV PACKAGE = EV PREFIX = ev_ +PROTOTYPES: ENABLE + BOOT: { int i; @@ -240,7 +250,9 @@ stash_periodic = gv_stashpv ("EV::Periodic", 1); stash_signal = gv_stashpv ("EV::Signal" , 1); stash_idle = gv_stashpv ("EV::Idle" , 1); + stash_prepare = gv_stashpv ("EV::Prepare" , 1); stash_check = gv_stashpv ("EV::Check" , 1); + stash_child = gv_stashpv ("EV::Child" , 1); { SV *sv = perl_get_sv ("EV::API", TRUE); @@ -268,8 +280,12 @@ evapi.signal_stop = evsignal_stop; evapi.idle_start = evidle_start; evapi.idle_stop = evidle_stop; + evapi.prepare_start = evprepare_start; + evapi.prepare_stop = evprepare_stop; evapi.check_start = evcheck_start; evapi.check_stop = evcheck_stop; + evapi.child_start = evchild_start; + evapi.child_stop = evchild_stop; sv_setiv (sv, (IV)&evapi); SvREADONLY_on (sv); @@ -299,7 +315,6 @@ ev_loop_done = value; struct ev_io *io (SV *fh, int events, SV *cb) - PROTOTYPE: $$& ALIAS: io_ns = 1 CODE: @@ -311,7 +326,6 @@ RETVAL struct ev_timer *timer (NV after, NV repeat, SV *cb) - PROTOTYPE: $$& ALIAS: timer_ns = 1 INIT: @@ -324,7 +338,6 @@ RETVAL struct ev_periodic *periodic (NV at, NV interval, SV *cb) - PROTOTYPE: $$& ALIAS: periodic_ns = 1 INIT: @@ -337,7 +350,6 @@ RETVAL struct ev_signal *signal (Signal signum, SV *cb) - PROTOTYPE: $& ALIAS: signal_ns = 1 CODE: @@ -348,7 +360,6 @@ RETVAL struct ev_idle *idle (SV *cb) - PROTOTYPE: & ALIAS: idle_ns = 1 CODE: @@ -358,8 +369,17 @@ OUTPUT: RETVAL +struct ev_prepare *prepare (SV *cb) + ALIAS: + prepare_ns = 1 + CODE: + RETVAL = e_new (sizeof (struct ev_prepare), cb); + evprepare_set (RETVAL); + if (!ix) evprepare_start (RETVAL); + OUTPUT: + RETVAL + struct ev_check *check (SV *cb) - PROTOTYPE: & ALIAS: check_ns = 1 CODE: @@ -369,6 +389,16 @@ OUTPUT: RETVAL +struct ev_child *child (int pid, SV *cb) + ALIAS: + check_ns = 1 + CODE: + RETVAL = e_new (sizeof (struct ev_check), cb); + evchild_set (RETVAL, pid); + if (!ix) evchild_start (RETVAL); + OUTPUT: + RETVAL + PROTOTYPES: DISABLE @@ -509,12 +539,39 @@ void evidle_stop (struct ev_idle *w) +MODULE = EV PACKAGE = EV::Prepare PREFIX = evcheck_ + +void evprepare_start (struct ev_prepare *w) + +void evprepare_stop (struct ev_prepare *w) + MODULE = EV PACKAGE = EV::Check PREFIX = evcheck_ void evcheck_start (struct ev_check *w) void evcheck_stop (struct ev_check *w) +MODULE = EV PACKAGE = EV::Child PREFIX = evchild_ + +void evchild_start (struct ev_child *w) + +void evchild_stop (struct ev_child *w) + +void set (struct ev_child *w, int pid) + CODE: +{ + int active = w->active; + if (active) evchild_stop (w); + evchild_set (w, pid); + if (active) evchild_start (w); +} + +int status (struct ev_child *w) + CODE: + RETVAL = w->status; + OUTPUT: + RETVAL + #if 0 MODULE = EV PACKAGE = EV::DNS PREFIX = evdns_