… | |
… | |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 | |
|
|
34 | #ifdef EV_H |
|
|
35 | # include EV_H |
|
|
36 | #else |
|
|
37 | # include <ev.h> |
|
|
38 | #endif |
33 | |
39 | |
34 | #ifdef __cplusplus |
40 | #ifdef __cplusplus |
35 | extern "C" { |
41 | extern "C" { |
36 | #endif |
42 | #endif |
37 | |
43 | |
38 | #include "ev.h" |
44 | struct event_base; |
|
|
45 | |
|
|
46 | #define EVLIST_TIMEOUT 0x01 |
|
|
47 | #define EVLIST_INSERTED 0x02 |
|
|
48 | #define EVLIST_SIGNAL 0x04 |
|
|
49 | #define EVLIST_ACTIVE 0x08 |
|
|
50 | #define EVLIST_INTERNAL 0x10 |
|
|
51 | #define EVLIST_INIT 0x80 |
39 | |
52 | |
40 | struct event |
53 | struct event |
41 | { |
54 | { |
42 | /* lib watchers we map to */ |
55 | /* libev watchers we map onto */ |
43 | union { |
56 | union { |
44 | struct ev_io io; |
57 | struct ev_io io; |
45 | struct ev_signal sig; |
58 | struct ev_signal sig; |
46 | } iosig; |
59 | } iosig; |
47 | struct ev_timer to; |
60 | struct ev_timer to; |
… | |
… | |
51 | void (*ev_callback)(int, short, void *arg); |
64 | void (*ev_callback)(int, short, void *arg); |
52 | void *ev_arg; |
65 | void *ev_arg; |
53 | int ev_fd; |
66 | int ev_fd; |
54 | int ev_pri; |
67 | int ev_pri; |
55 | int ev_res; |
68 | int ev_res; |
|
|
69 | int ev_flags; |
56 | short ev_events; |
70 | short ev_events; |
57 | }; |
71 | }; |
58 | |
72 | |
59 | #define EV_PERSIST 0x10 |
73 | #define EV_PERSIST 0x10 |
60 | |
74 | |
61 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
75 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
62 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
76 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
63 | |
77 | |
64 | #define event_initialized(ev) 1 |
78 | #define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT) |
65 | |
79 | |
66 | #define evtimer_add(ev,tv) event_add (ev, tv) |
80 | #define evtimer_add(ev,tv) event_add (ev, tv) |
67 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
81 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
68 | #define evtimer_del(ev) event_del (ev) |
82 | #define evtimer_del(ev) event_del (ev) |
69 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
83 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
… | |
… | |
102 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
116 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg); |
103 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
117 | int event_once (int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
104 | |
118 | |
105 | int event_add (struct event *ev, struct timeval *tv); |
119 | int event_add (struct event *ev, struct timeval *tv); |
106 | int event_del (struct event *ev); |
120 | int event_del (struct event *ev); |
|
|
121 | void event_active (struct event *ev, int res, short ncalls); /* ncalls is being ignored */ |
107 | |
122 | |
108 | int event_pending (struct event *ev, short, struct timeval *tv); |
123 | int event_pending (struct event *ev, short, struct timeval *tv); |
109 | |
124 | |
110 | int event_priority_init (int npri); |
125 | int event_priority_init (int npri); |
111 | int event_priority_set (struct event *ev, int pri); |
126 | int event_priority_set (struct event *ev, int pri); |
112 | |
|
|
113 | struct event_base; |
|
|
114 | |
127 | |
115 | int event_base_set (struct event_base *base, struct event *ev); |
128 | int event_base_set (struct event_base *base, struct event *ev); |
116 | int event_base_loop (struct event_base *base, int); |
129 | int event_base_loop (struct event_base *base, int); |
117 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
130 | int event_base_loopexit (struct event_base *base, struct timeval *tv); |
118 | int event_base_dispatch (struct event_base *base); |
131 | int event_base_dispatch (struct event_base *base); |
119 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv); |
132 | 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_priority_init (struct event_base *base, int fd); |
133 | int event_base_priority_init (struct event_base *base, int fd); |
121 | |
134 | |
|
|
135 | #ifndef EV_STANDALONE |
|
|
136 | # include <event_compat.h> |
122 | #endif |
137 | #endif |
|
|
138 | |
|
|
139 | #ifdef __cplusplus |
|
|
140 | } |
|
|
141 | #endif |
|
|
142 | |
|
|
143 | #endif |
|
|
144 | |