static void (*method_modify)(int fd, int oev, int nev);
static void (*method_poll)(ev_tstamp timeout);
+/*****************************************************************************/
+
ev_tstamp
ev_time (void)
{
cur = newcnt; \
}
+/*****************************************************************************/
+
typedef struct
{
struct ev_io *head;
}
}
+/*****************************************************************************/
+
static struct ev_timer **atimers;
static int atimermax, atimercnt;
timers [k]->active = k + 1;
}
+/*****************************************************************************/
+
typedef struct
{
struct ev_signal *head;
evio_start (&sigev);
}
+/*****************************************************************************/
+
#if HAVE_EPOLL
# include "ev_epoll.c"
#endif
return ev_method;
}
+/*****************************************************************************/
+
void ev_prefork (void)
{
}
siginit ();
}
+/*****************************************************************************/
+
+static ev_hook hooks [EVHOOK_NUM];
+
+void
+ev_hook_register (int type, ev_hook hook)
+{
+ hooks [type] = hook;
+}
+
+void
+ev_hook_unregister (int type, ev_hook hook)
+{
+ hooks [type] = 0;
+}
+
+static void
+hook_call (int type)
+{
+ if (hooks [type])
+ hooks [type] ();
+}
+
static void
fd_reify (void)
{
do
{
+ hook_call (EVHOOK_PREPOLL);
+
/* update fd-related kernel structures */
fd_reify ();
/* update ev_now, do magic */
time_update ();
+ hook_call (EVHOOK_POSTPOLL);
+
/* put pending timers into pendign queue and reschedule them */
/* absolute timers first */
timers_reify (atimers, atimercnt, ev_now);
while (!ev_loop_done);
}
+/*****************************************************************************/
+
static void
wlist_add (struct ev_watcher_list **head, struct ev_watcher_list *elem)
{
/* nop */
}
+/*****************************************************************************/
+
void
evio_start (struct ev_io *w)
{
struct ev_timer t[10000];
-#if 0
+#if 1
int i;
for (i = 0; i < 10000; ++i)
{
void ev_loop (int flags);
extern int ev_loop_done; /* set to 1 to break out of event loop */
+#define EVHOOK_PREPOLL 0 /* called before updating fds, timers and blocking */
+#define EVHOOK_POSTPOLL 1 /* called after blocking */
+#define EVHOOK_NUM 2 /* just the # of hooks */
+typedef void (*ev_hook)(void);
+void ev_hook_register (int type, ev_hook hook);
+void ev_hook_unregister (int type, ev_hook hook);
+
/* these may evaluate ev multiple times, and the other arguments at most once */
#define evw_init(ev,cb_,data_) do { (ev)->active = 0; (ev)->cb = (cb_); (ev)->data = (void *)data_; } while (0)