From 89a42941133287392b81c95fca09de34118f1a30 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 24 Oct 2010 18:09:58 +0000 Subject: *** empty log message *** --- ev.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'ev.c') diff --git a/ev.c b/ev.c index 20a2c9a..12dffb3 100644 --- a/ev.c +++ b/ev.c @@ -1814,6 +1814,9 @@ ev_loop_destroy (EV_P) #endif #if EV_FORK_ENABLE array_free (fork, EMPTY); +#endif +#if EV_CLEANUP_ENABLE + array_free (cleanup, EMPTY); #endif array_free (prepare, EMPTY); array_free (check, EMPTY); @@ -1987,6 +1990,11 @@ ev_verify (EV_P) array_verify (EV_A_ (W *)forks, forkcnt); #endif +#if EV_CLEANUP_ENABLE + assert (cleanupmax >= cleanupcnt); + array_verify (EV_A_ (W *)cleanups, cleanupcnt); +#endif + #if EV_ASYNC_ENABLE assert (asyncmax >= asynccnt); array_verify (EV_A_ (W *)asyncs, asynccnt); @@ -3564,6 +3572,44 @@ ev_fork_stop (EV_P_ ev_fork *w) } #endif +#if EV_CLEANUP_ENABLE +void +ev_cleanup_start (EV_P_ ev_cleanup *w) +{ + if (expect_false (ev_is_active (w))) + return; + + EV_FREQUENT_CHECK; + + ev_start (EV_A_ (W)w, ++cleanupcnt); + array_needsize (ev_cleanup *, cleanups, cleanupmax, cleanupcnt, EMPTY2); + cleanups [cleanupcnt - 1] = w; + + EV_FREQUENT_CHECK; +} + +void +ev_cleanup_stop (EV_P_ ev_cleanup *w) +{ + clear_pending (EV_A_ (W)w); + if (expect_false (!ev_is_active (w))) + return; + + EV_FREQUENT_CHECK; + + { + int active = ev_active (w); + + cleanups [active - 1] = cleanups [--cleanupcnt]; + ev_active (cleanups [active - 1]) = active; + } + + ev_stop (EV_A_ (W)w); + + EV_FREQUENT_CHECK; +} +#endif + #if EV_ASYNC_ENABLE void ev_async_start (EV_P_ ev_async *w) -- cgit v1.2.3