diff options
author | root <root> | 2010-10-24 18:09:58 +0000 |
---|---|---|
committer | root <root> | 2010-10-24 18:09:58 +0000 |
commit | 89a42941133287392b81c95fca09de34118f1a30 (patch) | |
tree | 42cc9495cd864a1d34c976d34129fa7431c833f7 /ev.c | |
parent | e4b847e9394cc24b2edd689a7cae8243973c10ef (diff) |
*** empty log message ***
Diffstat (limited to 'ev.c')
-rw-r--r-- | ev.c | 46 |
1 files changed, 46 insertions, 0 deletions
@@ -1815,6 +1815,9 @@ ev_loop_destroy (EV_P) #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); #if EV_ASYNC_ENABLE @@ -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) |