ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.h
(Generate patch)

Comparing libev/ev.h (file contents):
Revision 1.65 by root, Sat Nov 24 06:23:27 2007 UTC vs.
Revision 1.66 by root, Sat Nov 24 07:14:26 2007 UTC

125#define EV_WATCHER_TIME(type) \ 125#define EV_WATCHER_TIME(type) \
126 EV_WATCHER (type) \ 126 EV_WATCHER (type) \
127 ev_tstamp at; /* private */ 127 ev_tstamp at; /* private */
128 128
129/* base class, nothing to see here unless you subclass */ 129/* base class, nothing to see here unless you subclass */
130struct ev_watcher 130typedef struct ev_watcher
131{ 131{
132 EV_WATCHER (ev_watcher) 132 EV_WATCHER (ev_watcher)
133}; 133} ev_watcher;
134 134
135/* base class, nothing to see here unless you subclass */ 135/* base class, nothing to see here unless you subclass */
136struct ev_watcher_list 136typedef struct ev_watcher_list
137{ 137{
138 EV_WATCHER_LIST (ev_watcher_list) 138 EV_WATCHER_LIST (ev_watcher_list)
139}; 139} ev_watcher_list;
140 140
141/* base class, nothing to see here unless you subclass */ 141/* base class, nothing to see here unless you subclass */
142struct ev_watcher_time 142typedef struct ev_watcher_time
143{ 143{
144 EV_WATCHER_TIME (ev_watcher_time) 144 EV_WATCHER_TIME (ev_watcher_time)
145}; 145} ev_watcher_time;
146 146
147/* invoked after a specific time, repeatable (based on monotonic clock) */ 147/* invoked after a specific time, repeatable (based on monotonic clock) */
148/* revent EV_TIMEOUT */ 148/* revent EV_TIMEOUT */
149struct ev_timer 149typedef struct ev_timer
150{ 150{
151 EV_WATCHER_TIME (ev_timer) 151 EV_WATCHER_TIME (ev_timer)
152 152
153 ev_tstamp repeat; /* rw */ 153 ev_tstamp repeat; /* rw */
154}; 154} ev_timer;
155 155
156/* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */ 156/* invoked at some specific time, possibly repeating at regular intervals (based on UTC) */
157/* revent EV_PERIODIC */ 157/* revent EV_PERIODIC */
158struct ev_periodic 158typedef struct ev_periodic
159{ 159{
160 EV_WATCHER_TIME (ev_periodic) 160 EV_WATCHER_TIME (ev_periodic)
161 161
162 ev_tstamp interval; /* rw */ 162 ev_tstamp interval; /* rw */
163 ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */ 163 ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */
164}; 164} ev_periodic;
165 165
166/* invoked when fd is either EV_READable or EV_WRITEable */ 166/* invoked when fd is either EV_READable or EV_WRITEable */
167/* revent EV_READ, EV_WRITE */ 167/* revent EV_READ, EV_WRITE */
168struct ev_io 168typedef struct ev_io
169{ 169{
170 EV_WATCHER_LIST (ev_io) 170 EV_WATCHER_LIST (ev_io)
171 171
172 int fd; /* ro */ 172 int fd; /* ro */
173 int events; /* ro */ 173 int events; /* ro */
174}; 174} ev_io;
175 175
176/* invoked when the given signal has been received */ 176/* invoked when the given signal has been received */
177/* revent EV_SIGNAL */ 177/* revent EV_SIGNAL */
178struct ev_signal 178typedef struct ev_signal
179{ 179{
180 EV_WATCHER_LIST (ev_signal) 180 EV_WATCHER_LIST (ev_signal)
181 181
182 int signum; /* ro */ 182 int signum; /* ro */
183}; 183} ev_signal;
184 184
185/* invoked when the nothing else needs to be done, keeps the process from blocking */ 185/* invoked when the nothing else needs to be done, keeps the process from blocking */
186/* revent EV_IDLE */ 186/* revent EV_IDLE */
187struct ev_idle 187typedef struct ev_idle
188{ 188{
189 EV_WATCHER (ev_idle) 189 EV_WATCHER (ev_idle)
190}; 190} ev_idle;
191 191
192/* invoked for each run of the mainloop, just before the blocking call */ 192/* invoked for each run of the mainloop, just before the blocking call */
193/* you can still change events in any way you like */ 193/* you can still change events in any way you like */
194/* revent EV_PREPARE */ 194/* revent EV_PREPARE */
195struct ev_prepare 195typedef struct ev_prepare
196{ 196{
197 EV_WATCHER (ev_prepare) 197 EV_WATCHER (ev_prepare)
198}; 198} ev_prepare;
199 199
200/* invoked for each run of the mainloop, just after the blocking call */ 200/* invoked for each run of the mainloop, just after the blocking call */
201/* revent EV_CHECK */ 201/* revent EV_CHECK */
202struct ev_check 202typedef struct ev_check
203{ 203{
204 EV_WATCHER (ev_check) 204 EV_WATCHER (ev_check)
205}; 205} ev_check;
206 206
207/* invoked when sigchld is received and waitpid indicates the given pid */ 207/* invoked when sigchld is received and waitpid indicates the given pid */
208/* revent EV_CHILD */ 208/* revent EV_CHILD */
209/* does not support priorities */ 209/* does not support priorities */
210struct ev_child 210typedef struct ev_child
211{ 211{
212 EV_WATCHER_LIST (ev_child) 212 EV_WATCHER_LIST (ev_child)
213 213
214 int pid; /* ro */ 214 int pid; /* ro */
215 int rpid; /* rw, holds the received pid */ 215 int rpid; /* rw, holds the received pid */
216 int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */ 216 int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
217}; 217} ev_child;
218 218
219#if EV_MULTIPLICITY 219#if EV_MULTIPLICITY
220/* used to embed an event loop inside another */ 220/* used to embed an event loop inside another */
221/* the callback gets invoked when the event loop has handled events, and can be 0 */ 221/* the callback gets invoked when the event loop has handled events, and can be 0 */
222struct ev_embed 222typedef struct ev_embed
223{ 223{
224 EV_WATCHER (ev_embed) 224 EV_WATCHER (ev_embed)
225 225
226 struct ev_io io; /* private */ 226 ev_io io; /* private */
227 struct ev_loop *loop; /* ro */ 227 struct ev_loop *loop; /* ro */
228}; 228} ev_embed;
229#endif 229#endif
230 230
231/* the presence of this union forces similar struct layout */ 231/* the presence of this union forces similar struct layout */
232union ev_any_watcher 232union ev_any_watcher
233{ 233{
351#endif 351#endif
352 352
353/* these may evaluate ev multiple times, and the other arguments at most once */ 353/* these may evaluate ev multiple times, and the other arguments at most once */
354/* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ 354/* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */
355#define ev_init(ev,cb_) do { \ 355#define ev_init(ev,cb_) do { \
356 ((struct ev_watcher *)(void *)(ev))->active = \ 356 ((ev_watcher *)(void *)(ev))->active = \
357 ((struct ev_watcher *)(void *)(ev))->pending = \ 357 ((ev_watcher *)(void *)(ev))->pending = \
358 ((struct ev_watcher *)(void *)(ev))->priority = 0; \ 358 ((ev_watcher *)(void *)(ev))->priority = 0; \
359 ev_set_cb ((ev), cb_); \ 359 ev_set_cb ((ev), cb_); \
360} while (0) 360} while (0)
361 361
362#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) 362#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0)
363#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) 363#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0)
377#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) 377#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
378#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) 378#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
379#define ev_child_init(ev,cb,pid) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0) 379#define ev_child_init(ev,cb,pid) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0)
380#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0) 380#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0)
381 381
382#define ev_is_pending(ev) (0 + ((struct ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 382#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
383#define ev_is_active(ev) (0 + ((struct ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ 383#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
384 384
385#define ev_priority(ev) ((struct ev_watcher *)(void *)(ev))->priority /* rw */ 385#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */
386#define ev_cb(ev) (ev)->cb /* rw */ 386#define ev_cb(ev) (ev)->cb /* rw */
387#define ev_set_priority(ev,pri) ev_priority (ev) = (pri) 387#define ev_set_priority(ev,pri) ev_priority (ev) = (pri)
388 388
389#ifndef ev_set_cb 389#ifndef ev_set_cb
390# define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_) 390# define ev_set_cb(ev,cb_) ev_cb (ev) = (cb_)
398/* accepts any ev_watcher type */ 398/* accepts any ev_watcher type */
399void ev_feed_event (EV_P_ void *w, int revents); 399void ev_feed_event (EV_P_ void *w, int revents);
400void ev_feed_fd_event (EV_P_ int fd, int revents); 400void ev_feed_fd_event (EV_P_ int fd, int revents);
401void ev_feed_signal_event (EV_P_ int signum); 401void ev_feed_signal_event (EV_P_ int signum);
402 402
403void ev_io_start (EV_P_ struct ev_io *w); 403void ev_io_start (EV_P_ ev_io *w);
404void ev_io_stop (EV_P_ struct ev_io *w); 404void ev_io_stop (EV_P_ ev_io *w);
405 405
406void ev_timer_start (EV_P_ struct ev_timer *w); 406void ev_timer_start (EV_P_ ev_timer *w);
407void ev_timer_stop (EV_P_ struct ev_timer *w); 407void ev_timer_stop (EV_P_ ev_timer *w);
408/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */ 408/* stops if active and no repeat, restarts if active and repeating, starts if inactive and repeating */
409void ev_timer_again (EV_P_ struct ev_timer *w); 409void ev_timer_again (EV_P_ ev_timer *w);
410 410
411#if EV_PERIODICS 411#if EV_PERIODICS
412void ev_periodic_start (EV_P_ struct ev_periodic *w); 412void ev_periodic_start (EV_P_ ev_periodic *w);
413void ev_periodic_stop (EV_P_ struct ev_periodic *w); 413void ev_periodic_stop (EV_P_ ev_periodic *w);
414void ev_periodic_again (EV_P_ struct ev_periodic *w); 414void ev_periodic_again (EV_P_ ev_periodic *w);
415#endif 415#endif
416 416
417void ev_idle_start (EV_P_ struct ev_idle *w); 417void ev_idle_start (EV_P_ ev_idle *w);
418void ev_idle_stop (EV_P_ struct ev_idle *w); 418void ev_idle_stop (EV_P_ ev_idle *w);
419 419
420void ev_prepare_start (EV_P_ struct ev_prepare *w); 420void ev_prepare_start (EV_P_ ev_prepare *w);
421void ev_prepare_stop (EV_P_ struct ev_prepare *w); 421void ev_prepare_stop (EV_P_ ev_prepare *w);
422 422
423void ev_check_start (EV_P_ struct ev_check *w); 423void ev_check_start (EV_P_ ev_check *w);
424void ev_check_stop (EV_P_ struct ev_check *w); 424void ev_check_stop (EV_P_ ev_check *w);
425 425
426/* only supported in the default loop */ 426/* only supported in the default loop */
427void ev_signal_start (EV_P_ struct ev_signal *w); 427void ev_signal_start (EV_P_ ev_signal *w);
428void ev_signal_stop (EV_P_ struct ev_signal *w); 428void ev_signal_stop (EV_P_ ev_signal *w);
429 429
430/* only supported in the default loop */ 430/* only supported in the default loop */
431void ev_child_start (EV_P_ struct ev_child *w); 431void ev_child_start (EV_P_ ev_child *w);
432void ev_child_stop (EV_P_ struct ev_child *w); 432void ev_child_stop (EV_P_ ev_child *w);
433 433
434# if EV_MULTIPLICITY 434# if EV_MULTIPLICITY
435/* only supported when loop to be embedded is in fact embeddable */ 435/* only supported when loop to be embedded is in fact embeddable */
436void ev_embed_start (EV_P_ struct ev_embed *w); 436void ev_embed_start (EV_P_ ev_embed *w);
437void ev_embed_stop (EV_P_ struct ev_embed *w); 437void ev_embed_stop (EV_P_ ev_embed *w);
438void ev_embed_loop (EV_P_ ev_embed *w);
438# endif 439# endif
439 440
440#endif 441#endif
441 442
442#ifdef __cplusplus 443#ifdef __cplusplus

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines