--- cvsroot/EV/EV.xs 2010/07/08 00:45:03 1.141 +++ cvsroot/EV/EV.xs 2010/10/24 19:01:01 1.145 @@ -122,6 +122,7 @@ *stash_check, *stash_embed, *stash_fork, + *stash_cleanup, *stash_async; ///////////////////////////////////////////////////////////////////////////// @@ -366,8 +367,7 @@ const_iv (EV_, READ) const_iv (EV_, WRITE) const_iv (EV_, IO) - const_iv (EV_, TIMEOUT) /* deprecated */ - const_iv (EV_, TIMER) + const_iv (EV_, TIMEOUT) const_iv (EV_, PERIODIC) const_iv (EV_, SIGNAL) const_iv (EV_, CHILD) @@ -377,17 +377,17 @@ 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) - 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) + const_iv (EV, RUN_NOWAIT) + const_iv (EV, RUN_ONCE) + const_iv (EV, BREAK_CANCEL) + const_iv (EV, BREAK_ONE) + const_iv (EV, BREAK_ALL) const_iv (EV, BACKEND_SELECT) const_iv (EV, BACKEND_POLL) const_iv (EV, BACKEND_EPOLL) @@ -404,6 +404,16 @@ const_iv (EV_, VERSION_MAJOR) const_iv (EV_, VERSION_MINOR) +#if EV_COMPAT3 + const_iv (EV_, TIMER) + + 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) +#endif }; for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) @@ -422,6 +432,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); { @@ -450,7 +461,7 @@ evapi.suspend = ev_suspend; evapi.resume = ev_resume; evapi.backend = ev_backend; - evapi.unloop = ev_unloop; + evapi.break_ = ev_break; evapi.invoke_pending = ev_invoke_pending; evapi.pending_count = ev_pending_count; evapi.verify = ev_verify; @@ -458,7 +469,7 @@ evapi.set_invoke_pending_cb= ev_set_invoke_pending_cb; evapi.ref = ev_ref; evapi.unref = ev_unref; - evapi.loop = ev_loop; + evapi.run = ev_run; evapi.once = ev_once; evapi.io_start = ev_io_start; evapi.io_stop = ev_io_stop; @@ -488,6 +499,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; @@ -522,7 +535,7 @@ void ev_default_destroy () CODE: - ev_default_destroy (); + ev_loop_destroy (EV_DEFAULT_UC); SvREFCNT_dec (default_loop_sv); default_loop_sv = 0; @@ -552,12 +565,18 @@ C_ARGS: evapi.default_loop void ev_verify () + ALIAS: + loop_verify = 1 C_ARGS: evapi.default_loop unsigned int ev_iteration () + ALIAS: + loop_count = 1 C_ARGS: evapi.default_loop unsigned int ev_depth () + ALIAS: + loop_depth = 1 C_ARGS: evapi.default_loop void ev_set_io_collect_interval (NV interval) @@ -566,10 +585,14 @@ void ev_set_timeout_collect_interval (NV interval) C_ARGS: evapi.default_loop, interval -void ev_loop (int flags = 0) +void ev_run (int flags = 0) + ALIAS: + loop = 1 C_ARGS: evapi.default_loop, flags -void ev_unloop (int how = EVUNLOOP_ONE) +void ev_break (int how = EVBREAK_ONE) + ALIAS: + unloop = 1 C_ARGS: evapi.default_loop, how void ev_feed_fd_event (int fd, int revents = EV_NONE) @@ -697,6 +720,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: @@ -1087,6 +1119,21 @@ 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); + MODULE = EV PACKAGE = EV::Child PREFIX = ev_child_ #if EV_CHILD_ENABLE @@ -1287,13 +1334,13 @@ void DESTROY (struct ev_loop *loop) CODE: - if (loop != evapi.default_loop) /* global destruction sucks */ + /* 1. the default loop shouldn't be freed by destroying it'S pelr loop object */ + /* 2. not doing so helps avoid many global destruction bugs in perl, too */ + if (loop != evapi.default_loop) ev_loop_destroy (loop); void ev_loop_fork (struct ev_loop *loop) -void ev_verify (struct ev_loop *loop) - NV ev_now (struct ev_loop *loop) void ev_now_update (struct ev_loop *loop) @@ -1308,13 +1355,25 @@ unsigned int ev_backend (struct ev_loop *loop) +void ev_verify (struct ev_loop *loop) + ALIAS: + loop_verify = 1 + unsigned int ev_iteration (struct ev_loop *loop) + ALIAS: + loop_count = 1 unsigned int ev_depth (struct ev_loop *loop) + ALIAS: + loop_depth = 1 -void ev_loop (struct ev_loop *loop, int flags = 0) +void ev_run (struct ev_loop *loop, int flags = 0) + ALIAS: + loop = 1 -void ev_unloop (struct ev_loop *loop, int how = 1) +void ev_break (struct ev_loop *loop, int how = 1) + ALIAS: + unloop = 1 void ev_feed_fd_event (struct ev_loop *loop, int fd, int revents = EV_NONE) @@ -1435,6 +1494,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: