4 typedef double ev_tstamp;
6 /* eventmask, revents, events... */
7 #define EV_UNDEF -1 /* guaranteed to be invalid */
14 /* shared by all watchers */
15 #define EV_WATCHER(type) \
16 int active; /* private */ \
17 int pending; /* private */ \
18 void *data; /* rw */ \
19 void (*cb)(struct type *, int revents) /* rw */
21 #define EV_WATCHER_LIST(type) \
23 struct type *next /* private */
27 EV_WATCHER_LIST (ev_timer);
29 ev_tstamp at; /* private */
30 ev_tstamp repeat; /* rw */
31 unsigned char is_abs; /* ro */
36 EV_WATCHER_LIST (ev_io);
44 EV_WATCHER_LIST (ev_signal);
49 #define EVMETHOD_NONE 0
50 #define EVMETHOD_SELECT 1
51 #define EVMETHOD_EPOLL 2
52 int ev_init (int flags);
55 void ev_prefork (void);
56 void ev_postfork_parent (void);
57 void ev_postfork_child (void);
59 extern ev_tstamp ev_now; /* time w.r.t. timers and the eventloop, updated after each poll */
60 ev_tstamp ev_time (void);
62 #define EVLOOP_NONBLOCK 1 /* do not block/wait */
63 #define EVLOOP_ONESHOT 2 /* block *once* only */
64 void ev_loop (int flags);
65 extern int ev_loop_done; /* set to 1 to break out of event loop */
67 /* these may evaluate ev multiple times, and the other arguments at most once */
68 #define evw_init(ev,cb_,data_) do { (ev)->active = 0; (ev)->cb = (cb_); (ev)->data = (void *)data_; } while (0)
70 #define evio_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0)
71 #define evtimer_set_rel(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); (ev)->is_abs = 0; } while (0)
72 #define evtimer_set_abs(ev,at_,repeat_) do { (ev)->at = (at_); (ev)->repeat = (repeat_); (ev)->is_abs = 1; } while (0)
73 #define evsignal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
75 #define ev_is_active(ev) (0 + (ev)->active) /* true when the watcher has been started */
77 void evio_start (struct ev_io *w);
78 void evio_stop (struct ev_io *w);
80 void evtimer_start (struct ev_timer *w);
81 void evtimer_stop (struct ev_timer *w);
83 void evsignal_start (struct ev_signal *w);
84 void evsignal_stop (struct ev_signal *w);