summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2010-10-24 18:09:58 +0000
committerroot <root>2010-10-24 18:09:58 +0000
commit89a42941133287392b81c95fca09de34118f1a30 (patch)
tree42cc9495cd864a1d34c976d34129fa7431c833f7
parente4b847e9394cc24b2edd689a7cae8243973c10ef (diff)
*** empty log message ***
-rw-r--r--Symbols.ev4
-rw-r--r--ev.c46
-rw-r--r--ev.h6
-rw-r--r--ev_vars.h6
-rw-r--r--ev_wrap.h6
5 files changed, 63 insertions, 5 deletions
diff --git a/Symbols.ev b/Symbols.ev
index 92d03b8..f401b30 100644
--- a/Symbols.ev
+++ b/Symbols.ev
@@ -8,9 +8,7 @@ ev_check_stop
ev_child_start
ev_child_stop
ev_clear_pending
-ev_default_destroy
-ev_default_fork
-ev_default_loop_init
+ev_default_loop
ev_default_loop_ptr
ev_depth
ev_embed_start
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)
diff --git a/ev.h b/ev.h
index adc038b..f0ffd4f 100644
--- a/ev.h
+++ b/ev.h
@@ -100,11 +100,11 @@ EV_CPP(extern "C" {)
#endif
#ifndef EV_FORK_ENABLE
-# define EV_FORK_ENABLE 0 /* not implemented */
+# define EV_FORK_ENABLE EV_FEATURE_WATCHERS
#endif
#ifndef EV_CLEANUP_ENABLE
-# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
+# define EV_CLEANUP_ENABLE 0 /* not implemented */
#endif
#ifndef EV_SIGNAL_ENABLE
@@ -427,7 +427,9 @@ typedef struct ev_embed
ev_periodic periodic; /* unused */
ev_idle idle; /* unused */
ev_fork fork; /* private */
+#if EV_CLEANUP_ENABLE
ev_cleanup cleanup; /* unused */
+#endif
} ev_embed;
#endif
diff --git a/ev_vars.h b/ev_vars.h
index 3f8f8ca..16d48ab 100644
--- a/ev_vars.h
+++ b/ev_vars.h
@@ -156,6 +156,12 @@ VARx(int, forkmax)
VARx(int, forkcnt)
#endif
+#if EV_CLEANUP_ENABLE || EV_GENWRAP
+VARx(struct ev_cleanup **, cleanups)
+VARx(int, cleanupmax)
+VARx(int, cleanupcnt)
+#endif
+
#if EV_ASYNC_ENABLE || EV_GENWRAP
VARx(EV_ATOMIC_T, async_pending)
VARx(struct ev_async **, asyncs)
diff --git a/ev_wrap.h b/ev_wrap.h
index a67cca3..9c19fe6 100644
--- a/ev_wrap.h
+++ b/ev_wrap.h
@@ -70,6 +70,9 @@
#define forks ((loop)->forks)
#define forkmax ((loop)->forkmax)
#define forkcnt ((loop)->forkcnt)
+#define cleanups ((loop)->cleanups)
+#define cleanupmax ((loop)->cleanupmax)
+#define cleanupcnt ((loop)->cleanupcnt)
#define async_pending ((loop)->async_pending)
#define asyncs ((loop)->asyncs)
#define asyncmax ((loop)->asyncmax)
@@ -159,6 +162,9 @@
#undef forks
#undef forkmax
#undef forkcnt
+#undef cleanups
+#undef cleanupmax
+#undef cleanupcnt
#undef async_pending
#undef asyncs
#undef asyncmax