… | |
… | |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
30 | */ |
31 | #ifndef _EVENT_H_ |
31 | #ifndef _EVENT_H_ |
32 | #define _EVENT_H_ |
32 | #define _EVENT_H_ |
33 | |
33 | |
|
|
34 | #include <ev.h> |
|
|
35 | |
34 | #ifdef __cplusplus |
36 | #ifdef __cplusplus |
35 | extern "C" { |
37 | extern "C" { |
36 | #endif |
38 | #endif |
37 | |
39 | |
38 | #include "ev.h" |
40 | struct event |
|
|
41 | { |
|
|
42 | /* libev watchers we map onto */ |
|
|
43 | union { |
|
|
44 | struct ev_io io; |
|
|
45 | struct ev_signal sig; |
|
|
46 | } iosig; |
|
|
47 | struct ev_timer to; |
39 | |
48 | |
40 | struct event |
49 | /* compatibility slots */ |
41 | { |
|
|
42 | struct ev_io io; |
|
|
43 | struct ev_timer to; |
|
|
44 | struct ev_signal sig; |
|
|
45 | |
|
|
46 | struct event_base *ev_base; |
50 | struct event_base *ev_base; |
47 | int ev_fd; |
|
|
48 | short ev_events; |
|
|
49 | int ev_pri; |
|
|
50 | void (*ev_callback)(int, short, void *arg); |
51 | void (*ev_callback)(int, short, void *arg); |
51 | void *ev_arg; |
52 | void *ev_arg; |
|
|
53 | int ev_fd; |
|
|
54 | int ev_pri; |
52 | int ev_res; |
55 | int ev_res; |
|
|
56 | short ev_events; |
53 | }; |
57 | }; |
54 | |
58 | |
55 | #define EV_PERSIST 0x10 |
59 | #define EV_PERSIST 0x10 |
56 | |
60 | |
57 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
61 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
… | |
… | |
98 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
102 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
99 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
103 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
100 | |
104 | |
101 | int event_add (struct event *ev, struct timeval *tv); |
105 | int event_add (struct event *ev, struct timeval *tv); |
102 | int event_del (struct event *ev); |
106 | int event_del (struct event *ev); |
103 | void event_active (struct event *ev, int fd, short events); |
107 | void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */ |
104 | |
108 | |
105 | int event_pending (struct event *ev, short, struct timeval *tv); |
109 | int event_pending (struct event *ev, short, struct timeval *tv); |
106 | |
110 | |
107 | int event_priority_init (int npri); |
111 | int event_priority_init (int npri); |
108 | int event_priority_set (struct event *ev, int pri); |
112 | int event_priority_set (struct event *ev, int pri); |
… | |
… | |
114 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
118 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
115 | int event_base_dispatch (struct event_base *base); |
119 | int event_base_dispatch (struct event_base *base); |
116 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
120 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
117 | int event_base_priority_init (struct event_base *base, int fd); |
121 | int event_base_priority_init (struct event_base *base, int fd); |
118 | |
122 | |
|
|
123 | #ifndef EV_STANDALONE |
|
|
124 | # include <event_compat.h> |
119 | #endif |
125 | #endif |
|
|
126 | |
|
|
127 | #ifdef __cplusplus |
|
|
128 | } |
|
|
129 | #endif |
|
|
130 | |
|
|
131 | #endif |
|
|
132 | |