… | |
… | |
31 | #define EV_H |
31 | #define EV_H |
32 | |
32 | |
33 | typedef double ev_tstamp; |
33 | typedef double ev_tstamp; |
34 | |
34 | |
35 | /* eventmask, revents, events... */ |
35 | /* eventmask, revents, events... */ |
36 | #define EV_UNDEF -1 /* guaranteed to be invalid */ |
36 | #define EV_UNDEF -1 /* guaranteed to be invalid */ |
37 | #define EV_NONE 0x00 |
37 | #define EV_NONE 0x00 |
38 | #define EV_READ 0x01 |
38 | #define EV_READ 0x01 |
39 | #define EV_WRITE 0x02 |
39 | #define EV_WRITE 0x02 |
40 | #define EV_REIFY 0x04 /* private */ |
|
|
41 | #define EV_TIMEOUT 0x000100 |
40 | #define EV_TIMEOUT 0x000100 |
|
|
41 | #define EV_PERIODIC 0x000200 |
42 | #define EV_SIGNAL 0x000200 |
42 | #define EV_SIGNAL 0x000400 |
43 | #define EV_IDLE 0x000400 |
43 | #define EV_IDLE 0x000800 |
44 | #define EV_CHECK 0x000800 |
44 | #define EV_CHECK 0x001000 |
45 | #define EV_PREPARE 0x001000 |
45 | #define EV_PREPARE 0x002000 |
46 | #define EV_CHILD 0x002000 |
46 | #define EV_CHILD 0x004000 |
47 | #define EV_ERROR 0x800000 /* sent when an error occurs */ |
47 | #define EV_ERROR 0x800000 /* sent when an error occurs */ |
48 | |
48 | |
49 | /* can be used to add custom fields to all watchers */ |
49 | /* can be used to add custom fields to all watchers */ |
50 | #ifndef EV_COMMON |
50 | #ifndef EV_COMMON |
51 | # define EV_COMMON void *data |
51 | # define EV_COMMON void *data |
52 | #endif |
52 | #endif |
… | |
… | |
93 | struct ev_watcher_time { |
93 | struct ev_watcher_time { |
94 | EV_WATCHER_TIME (ev_watcher_time); |
94 | EV_WATCHER_TIME (ev_watcher_time); |
95 | }; |
95 | }; |
96 | |
96 | |
97 | /* invoked after a specific time, repeatable (based on monotonic clock) */ |
97 | /* invoked after a specific time, repeatable (based on monotonic clock) */ |
|
|
98 | /* revent EV_TIMEOUT */ |
98 | struct ev_timer |
99 | struct ev_timer |
99 | { |
100 | { |
100 | EV_WATCHER_TIME (ev_timer); |
101 | EV_WATCHER_TIME (ev_timer); |
101 | |
102 | |
102 | ev_tstamp repeat; /* rw */ |
103 | ev_tstamp repeat; /* rw */ |
103 | }; |
104 | }; |
104 | |
105 | |
105 | /* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */ |
106 | /* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */ |
|
|
107 | /* revent EV_PERIODIC */ |
106 | struct ev_periodic |
108 | struct ev_periodic |
107 | { |
109 | { |
108 | EV_WATCHER_TIME (ev_periodic); |
110 | EV_WATCHER_TIME (ev_periodic); |
109 | |
111 | |
110 | ev_tstamp interval; /* rw */ |
112 | ev_tstamp interval; /* rw */ |
111 | }; |
113 | }; |
112 | |
114 | |
113 | /* invoked when fd is either EV_READable or EV_WRITEable */ |
115 | /* invoked when fd is either EV_READable or EV_WRITEable */ |
|
|
116 | /* revent EV_READ, EV_WRITE */ |
114 | struct ev_io |
117 | struct ev_io |
115 | { |
118 | { |
116 | EV_WATCHER_LIST (ev_io); |
119 | EV_WATCHER_LIST (ev_io); |
117 | |
120 | |
118 | int fd; /* ro */ |
121 | int fd; /* ro */ |
119 | int events; /* ro */ |
122 | int events; /* ro */ |
120 | }; |
123 | }; |
121 | |
124 | |
122 | /* invoked when the given signal has been received */ |
125 | /* invoked when the given signal has been received */ |
|
|
126 | /* revent EV_SIGNAL */ |
123 | struct ev_signal |
127 | struct ev_signal |
124 | { |
128 | { |
125 | EV_WATCHER_LIST (ev_signal); |
129 | EV_WATCHER_LIST (ev_signal); |
126 | |
130 | |
127 | int signum; /* ro */ |
131 | int signum; /* ro */ |
128 | }; |
132 | }; |
129 | |
133 | |
130 | /* invoked when the nothing else needs to be done, keeps the process from blocking */ |
134 | /* invoked when the nothing else needs to be done, keeps the process from blocking */ |
|
|
135 | /* revent EV_IDLE */ |
131 | struct ev_idle |
136 | struct ev_idle |
132 | { |
137 | { |
133 | EV_WATCHER (ev_idle); |
138 | EV_WATCHER (ev_idle); |
134 | }; |
139 | }; |
135 | |
140 | |
136 | /* invoked for each run of the mainloop, just before the blocking call */ |
141 | /* invoked for each run of the mainloop, just before the blocking call */ |
137 | /* you can still change events in any way you like */ |
142 | /* you can still change events in any way you like */ |
|
|
143 | /* revent EV_PREPARE */ |
138 | struct ev_prepare |
144 | struct ev_prepare |
139 | { |
145 | { |
140 | EV_WATCHER (ev_prepare); |
146 | EV_WATCHER (ev_prepare); |
141 | }; |
147 | }; |
142 | |
148 | |
143 | /* invoked for each run of the mainloop, just after the blocking call */ |
149 | /* invoked for each run of the mainloop, just after the blocking call */ |
|
|
150 | /* revent EV_CHECK */ |
144 | struct ev_check |
151 | struct ev_check |
145 | { |
152 | { |
146 | EV_WATCHER (ev_check); |
153 | EV_WATCHER (ev_check); |
147 | }; |
154 | }; |
148 | |
155 | |
149 | /* invoked when sigchld is received and waitpid indicates the givne pid */ |
156 | /* invoked when sigchld is received and waitpid indicates the givne pid */ |
|
|
157 | /* revent EV_CHILD */ |
150 | struct ev_child |
158 | struct ev_child |
151 | { |
159 | { |
152 | EV_WATCHER_LIST (ev_child); |
160 | EV_WATCHER_LIST (ev_child); |
153 | |
161 | |
154 | int pid; /* ro */ |
162 | int pid; /* ro */ |