summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c260
1 files changed, 130 insertions, 130 deletions
diff --git a/ev.c b/ev.c
index 255a9cd..86e366c 100644
--- a/ev.c
+++ b/ev.c
@@ -1560,87 +1560,6 @@ ev_periodic_again (EV_P_ ev_periodic *w)
}
#endif
-void
-ev_idle_start (EV_P_ ev_idle *w)
-{
- if (expect_false (ev_is_active (w)))
- return;
-
- ev_start (EV_A_ (W)w, ++idlecnt);
- array_needsize (ev_idle *, idles, idlemax, idlecnt, EMPTY2);
- idles [idlecnt - 1] = w;
-}
-
-void
-ev_idle_stop (EV_P_ ev_idle *w)
-{
- ev_clear_pending (EV_A_ (W)w);
- if (expect_false (!ev_is_active (w)))
- return;
-
- {
- int active = ((W)w)->active;
- idles [active - 1] = idles [--idlecnt];
- ((W)idles [active - 1])->active = active;
- }
-
- ev_stop (EV_A_ (W)w);
-}
-
-void
-ev_prepare_start (EV_P_ ev_prepare *w)
-{
- if (expect_false (ev_is_active (w)))
- return;
-
- ev_start (EV_A_ (W)w, ++preparecnt);
- array_needsize (ev_prepare *, prepares, preparemax, preparecnt, EMPTY2);
- prepares [preparecnt - 1] = w;
-}
-
-void
-ev_prepare_stop (EV_P_ ev_prepare *w)
-{
- ev_clear_pending (EV_A_ (W)w);
- if (expect_false (!ev_is_active (w)))
- return;
-
- {
- int active = ((W)w)->active;
- prepares [active - 1] = prepares [--preparecnt];
- ((W)prepares [active - 1])->active = active;
- }
-
- ev_stop (EV_A_ (W)w);
-}
-
-void
-ev_check_start (EV_P_ ev_check *w)
-{
- if (expect_false (ev_is_active (w)))
- return;
-
- ev_start (EV_A_ (W)w, ++checkcnt);
- array_needsize (ev_check *, checks, checkmax, checkcnt, EMPTY2);
- checks [checkcnt - 1] = w;
-}
-
-void
-ev_check_stop (EV_P_ ev_check *w)
-{
- ev_clear_pending (EV_A_ (W)w);
- if (expect_false (!ev_is_active (w)))
- return;
-
- {
- int active = ((W)w)->active;
- checks [active - 1] = checks [--checkcnt];
- ((W)checks [active - 1])->active = active;
- }
-
- ev_stop (EV_A_ (W)w);
-}
-
#ifndef SA_RESTART
# define SA_RESTART 0
#endif
@@ -1712,55 +1631,6 @@ ev_child_stop (EV_P_ ev_child *w)
ev_stop (EV_A_ (W)w);
}
-#if EV_EMBED_ENABLE
-void noinline
-ev_embed_sweep (EV_P_ ev_embed *w)
-{
- ev_loop (w->loop, EVLOOP_NONBLOCK);
-}
-
-static void
-embed_cb (EV_P_ ev_io *io, int revents)
-{
- ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io));
-
- if (ev_cb (w))
- ev_feed_event (EV_A_ (W)w, EV_EMBED);
- else
- ev_embed_sweep (loop, w);
-}
-
-void
-ev_embed_start (EV_P_ ev_embed *w)
-{
- if (expect_false (ev_is_active (w)))
- return;
-
- {
- struct ev_loop *loop = w->loop;
- assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
- ev_io_init (&w->io, embed_cb, backend_fd, EV_READ);
- }
-
- ev_set_priority (&w->io, ev_priority (w));
- ev_io_start (EV_A_ &w->io);
-
- ev_start (EV_A_ (W)w, 1);
-}
-
-void
-ev_embed_stop (EV_P_ ev_embed *w)
-{
- ev_clear_pending (EV_A_ (W)w);
- if (expect_false (!ev_is_active (w)))
- return;
-
- ev_io_stop (EV_A_ &w->io);
-
- ev_stop (EV_A_ (W)w);
-}
-#endif
-
#if EV_STAT_ENABLE
# ifdef _WIN32
@@ -1828,6 +1698,136 @@ ev_stat_stop (EV_P_ ev_stat *w)
}
#endif
+void
+ev_idle_start (EV_P_ ev_idle *w)
+{
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ ev_start (EV_A_ (W)w, ++idlecnt);
+ array_needsize (ev_idle *, idles, idlemax, idlecnt, EMPTY2);
+ idles [idlecnt - 1] = w;
+}
+
+void
+ev_idle_stop (EV_P_ ev_idle *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ {
+ int active = ((W)w)->active;
+ idles [active - 1] = idles [--idlecnt];
+ ((W)idles [active - 1])->active = active;
+ }
+
+ ev_stop (EV_A_ (W)w);
+}
+
+void
+ev_prepare_start (EV_P_ ev_prepare *w)
+{
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ ev_start (EV_A_ (W)w, ++preparecnt);
+ array_needsize (ev_prepare *, prepares, preparemax, preparecnt, EMPTY2);
+ prepares [preparecnt - 1] = w;
+}
+
+void
+ev_prepare_stop (EV_P_ ev_prepare *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ {
+ int active = ((W)w)->active;
+ prepares [active - 1] = prepares [--preparecnt];
+ ((W)prepares [active - 1])->active = active;
+ }
+
+ ev_stop (EV_A_ (W)w);
+}
+
+void
+ev_check_start (EV_P_ ev_check *w)
+{
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ ev_start (EV_A_ (W)w, ++checkcnt);
+ array_needsize (ev_check *, checks, checkmax, checkcnt, EMPTY2);
+ checks [checkcnt - 1] = w;
+}
+
+void
+ev_check_stop (EV_P_ ev_check *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ {
+ int active = ((W)w)->active;
+ checks [active - 1] = checks [--checkcnt];
+ ((W)checks [active - 1])->active = active;
+ }
+
+ ev_stop (EV_A_ (W)w);
+}
+
+#if EV_EMBED_ENABLE
+void noinline
+ev_embed_sweep (EV_P_ ev_embed *w)
+{
+ ev_loop (w->loop, EVLOOP_NONBLOCK);
+}
+
+static void
+embed_cb (EV_P_ ev_io *io, int revents)
+{
+ ev_embed *w = (ev_embed *)(((char *)io) - offsetof (ev_embed, io));
+
+ if (ev_cb (w))
+ ev_feed_event (EV_A_ (W)w, EV_EMBED);
+ else
+ ev_embed_sweep (loop, w);
+}
+
+void
+ev_embed_start (EV_P_ ev_embed *w)
+{
+ if (expect_false (ev_is_active (w)))
+ return;
+
+ {
+ struct ev_loop *loop = w->loop;
+ assert (("loop to be embedded is not embeddable", backend & ev_embeddable_backends ()));
+ ev_io_init (&w->io, embed_cb, backend_fd, EV_READ);
+ }
+
+ ev_set_priority (&w->io, ev_priority (w));
+ ev_io_start (EV_A_ &w->io);
+
+ ev_start (EV_A_ (W)w, 1);
+}
+
+void
+ev_embed_stop (EV_P_ ev_embed *w)
+{
+ ev_clear_pending (EV_A_ (W)w);
+ if (expect_false (!ev_is_active (w)))
+ return;
+
+ ev_io_stop (EV_A_ &w->io);
+
+ ev_stop (EV_A_ (W)w);
+}
+#endif
+
/*****************************************************************************/
struct ev_once