--- cvsroot/EV/EV.xs 2010/10/24 17:58:41 1.144 +++ cvsroot/EV/EV.xs 2010/11/28 11:40:41 1.150 @@ -122,6 +122,7 @@ *stash_check, *stash_embed, *stash_fork, + *stash_cleanup, *stash_async; ///////////////////////////////////////////////////////////////////////////// @@ -342,6 +343,12 @@ #define CHECK_SIG(sv,num) if ((num) < 0) \ croak ("illegal signal number or name: %s", SvPV_nolen (sv)); +static void +default_fork (void) +{ + ev_loop_fork (EV_DEFAULT_UC); +} + ///////////////////////////////////////////////////////////////////////////// // XS interface functions @@ -366,7 +373,7 @@ const_iv (EV_, READ) const_iv (EV_, WRITE) const_iv (EV_, IO) - const_iv (EV_, TIMEOUT) + const_iv (EV_, TIMER) const_iv (EV_, PERIODIC) const_iv (EV_, SIGNAL) const_iv (EV_, CHILD) @@ -376,6 +383,7 @@ const_iv (EV_, CHECK) const_iv (EV_, EMBED) const_iv (EV_, FORK) + const_iv (EV_, CLEANUP) const_iv (EV_, ASYNC) const_iv (EV_, CUSTOM) const_iv (EV_, ERROR) @@ -397,17 +405,15 @@ const_iv (EV, FLAG_FORKCHECK) const_iv (EV, FLAG_SIGNALFD) const_iv (EV, FLAG_NOENV) - const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ const_iv (EV, FLAG_NOINOTIFY) const_iv (EV_, VERSION_MAJOR) const_iv (EV_, VERSION_MINOR) #if EV_COMPAT3 - const_iv (EV_, TIMER) - + const_iv (EV, FLAG_NOSIGFD) /* compatibility, always 0 */ + const_iv (EV_, TIMEOUT) const_iv (EV, LOOP_NONBLOCK) const_iv (EV, LOOP_ONESHOT) - const_iv (EV, UNLOOP_CANCEL) const_iv (EV, UNLOOP_ONE) const_iv (EV, UNLOOP_ALL) @@ -430,6 +436,7 @@ stash_embed = gv_stashpv ("EV::Embed" , 1); stash_stat = gv_stashpv ("EV::Stat" , 1); stash_fork = gv_stashpv ("EV::Fork" , 1); + stash_cleanup = gv_stashpv ("EV::Cleanup" , 1); stash_async = gv_stashpv ("EV::Async" , 1); { @@ -496,6 +503,8 @@ evapi.embed_sweep = ev_embed_sweep; evapi.fork_start = ev_fork_start; evapi.fork_stop = ev_fork_stop; + evapi.cleanup_start = ev_cleanup_start; + evapi.cleanup_stop = ev_cleanup_stop; evapi.async_start = ev_async_start; evapi.async_stop = ev_async_stop; evapi.async_send = ev_async_send; @@ -506,7 +515,7 @@ SvREADONLY_on (sv); } #if !defined(_WIN32) && !defined(_MINIX) - pthread_atfork (0, 0, ev_default_fork); + pthread_atfork (0, 0, default_fork); #endif } @@ -715,6 +724,15 @@ OUTPUT: RETVAL +ev_cleanup *cleanup (SV *cb) + ALIAS: + cleanup_ns = 1 + CODE: + RETVAL = e_new (sizeof (ev_cleanup), cb, default_loop_sv); + ev_cleanup_set (RETVAL); + if (!ix) START (cleanup, RETVAL); + OUTPUT: + RETVAL ev_child *child (int pid, int trace, SV *cb) ALIAS: @@ -742,6 +760,8 @@ OUTPUT: RETVAL +#ifndef EV_NO_LOOPS + ev_embed *embed (struct ev_loop *loop, SV *cb = 0) ALIAS: embed_ns = 1 @@ -758,6 +778,8 @@ OUTPUT: RETVAL +#endif + ev_async *async (SV *cb) ALIAS: async_ns = 1 @@ -1105,6 +1127,27 @@ STOP (fork, w); e_destroy (w); +MODULE = EV PACKAGE = EV::Cleanup PREFIX = ev_cleanup_ + +void ev_cleanup_start (ev_cleanup *w) + CODE: + START (cleanup, w); + +void ev_cleanup_stop (ev_cleanup *w) + CODE: + STOP (cleanup, w); + +void DESTROY (ev_cleanup *w) + CODE: + STOP (cleanup, w); + e_destroy (w); + +int keepalive (ev_watcher *w, int new_value = 0) + CODE: + RETVAL = 0; + OUTPUT: + RETVAL + MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ #if EV_CHILD_ENABLE @@ -1288,6 +1331,8 @@ OUTPUT: RETVAL +#ifndef EV_NO_LOOPS + MODULE = EV PACKAGE = EV::Loop PREFIX = ev_ SV *new (SV *klass, unsigned int flags = 0) @@ -1465,6 +1510,15 @@ OUTPUT: RETVAL +ev_cleanup *cleanup (struct ev_loop *loop, SV *cb) + ALIAS: + cleanup_ns = 1 + CODE: + RETVAL = e_new (sizeof (ev_cleanup), cb, ST (0)); + ev_cleanup_set (RETVAL); + if (!ix) START (cleanup, RETVAL); + OUTPUT: + RETVAL ev_child *child (struct ev_loop *loop, int pid, int trace, SV *cb) ALIAS: @@ -1527,3 +1581,5 @@ newSVsv (cb) ); +#endif +