summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/ev.c b/ev.c
index 20a2c9a..12dffb3 100644
--- a/ev.c
+++ b/ev.c
@@ -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)