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

Comparing libev/ev.h (file contents):
Revision 1.69 by root, Mon Nov 26 19:49:36 2007 UTC vs.
Revision 1.71 by root, Tue Nov 27 09:17:52 2007 UTC

159typedef struct ev_watcher_time 159typedef struct ev_watcher_time
160{ 160{
161 EV_WATCHER_TIME (ev_watcher_time) 161 EV_WATCHER_TIME (ev_watcher_time)
162} ev_watcher_time; 162} ev_watcher_time;
163 163
164/* invoked when fd is either EV_READable or EV_WRITEable */
165/* revent EV_READ, EV_WRITE */
166typedef struct ev_io
167{
168 EV_WATCHER_LIST (ev_io)
169
170 int fd; /* ro */
171 int events; /* ro */
172} ev_io;
173
164/* invoked after a specific time, repeatable (based on monotonic clock) */ 174/* invoked after a specific time, repeatable (based on monotonic clock) */
165/* revent EV_TIMEOUT */ 175/* revent EV_TIMEOUT */
166typedef struct ev_timer 176typedef struct ev_timer
167{ 177{
168 EV_WATCHER_TIME (ev_timer) 178 EV_WATCHER_TIME (ev_timer)
178 188
179 ev_tstamp interval; /* rw */ 189 ev_tstamp interval; /* rw */
180 ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */ 190 ev_tstamp (*reschedule_cb)(struct ev_periodic *w, ev_tstamp now); /* rw */
181} ev_periodic; 191} ev_periodic;
182 192
183/* invoked when fd is either EV_READable or EV_WRITEable */
184/* revent EV_READ, EV_WRITE */
185typedef struct ev_io
186{
187 EV_WATCHER_LIST (ev_io)
188
189 int fd; /* ro */
190 int events; /* ro */
191} ev_io;
192
193/* invoked when the given signal has been received */ 193/* invoked when the given signal has been received */
194/* revent EV_SIGNAL */ 194/* revent EV_SIGNAL */
195typedef struct ev_signal 195typedef struct ev_signal
196{ 196{
197 EV_WATCHER_LIST (ev_signal) 197 EV_WATCHER_LIST (ev_signal)
198 198
199 int signum; /* ro */ 199 int signum; /* ro */
200} ev_signal; 200} ev_signal;
201
202/* invoked when sigchld is received and waitpid indicates the given pid */
203/* revent EV_CHILD */
204/* does not support priorities */
205typedef struct ev_child
206{
207 EV_WATCHER_LIST (ev_child)
208
209 int pid; /* ro */
210 int rpid; /* rw, holds the received pid */
211 int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
212} ev_child;
213
214#if EV_STAT_ENABLE
215/* st_nlink = 0 means missing file or other error */
216#ifdef _WIN32
217typedef struct _stati64 ev_statdata;
218#else
219typedef struct stat ev_statdata;
220#endif
221
222/* invoked each time the stat data changes for a given path */
223/* revent EV_STAT */
224typedef struct ev_stat
225{
226 EV_WATCHER (ev_stat)
227
228 ev_timer timer; /* private */
229 ev_tstamp interval; /* ro */
230 const char *path; /* ro */
231 ev_statdata prev; /* ro */
232 ev_statdata attr; /* ro */
233} ev_stat;
234#endif
201 235
202/* invoked when the nothing else needs to be done, keeps the process from blocking */ 236/* invoked when the nothing else needs to be done, keeps the process from blocking */
203/* revent EV_IDLE */ 237/* revent EV_IDLE */
204typedef struct ev_idle 238typedef struct ev_idle
205{ 239{
219typedef struct ev_check 253typedef struct ev_check
220{ 254{
221 EV_WATCHER (ev_check) 255 EV_WATCHER (ev_check)
222} ev_check; 256} ev_check;
223 257
224/* invoked when sigchld is received and waitpid indicates the given pid */
225/* revent EV_CHILD */
226/* does not support priorities */
227typedef struct ev_child
228{
229 EV_WATCHER_LIST (ev_child)
230
231 int pid; /* ro */
232 int rpid; /* rw, holds the received pid */
233 int rstatus; /* rw, holds the exit status, use the macros from sys/wait.h */
234} ev_child;
235
236#if EV_EMBED_ENABLE 258#if EV_EMBED_ENABLE
237/* used to embed an event loop inside another */ 259/* used to embed an event loop inside another */
238/* the callback gets invoked when the event loop has handled events, and can be 0 */ 260/* the callback gets invoked when the event loop has handled events, and can be 0 */
239typedef struct ev_embed 261typedef struct ev_embed
240{ 262{
243 ev_io io; /* private */ 265 ev_io io; /* private */
244 struct ev_loop *loop; /* ro */ 266 struct ev_loop *loop; /* ro */
245} ev_embed; 267} ev_embed;
246#endif 268#endif
247 269
248#if EV_STAT_ENABLE
249/* st_nlink = 0 means missing file or other error */
250typedef struct stat ev_statdata;
251
252/* invoked each time the stat data changes for a given path */
253/* revent EV_STAT */
254typedef struct ev_stat
255{
256 EV_WATCHER (ev_stat)
257
258 ev_timer timer; /* private */
259 ev_tstamp interval; /* rw */
260 const char *path; /* ro */
261 ev_statdata prev; /* ro */
262 ev_statdata attr; /* ro */
263} ev_stat;
264#endif
265
266/* the presence of this union forces similar struct layout */ 270/* the presence of this union forces similar struct layout */
267union ev_any_watcher 271union ev_any_watcher
268{ 272{
269 struct ev_watcher w; 273 struct ev_watcher w;
270 struct ev_watcher_list wl; 274 struct ev_watcher_list wl;
271 275
272 struct ev_io io; 276 struct ev_io io;
273 struct ev_timer timer; 277 struct ev_timer timer;
274 struct ev_periodic periodic; 278 struct ev_periodic periodic;
279 struct ev_child child;
280#if EV_STAT_ENABLE
281 struct ev_stat stat;
282#endif
275 struct ev_idle idle; 283 struct ev_idle idle;
276 struct ev_prepare prepare; 284 struct ev_prepare prepare;
277 struct ev_check check; 285 struct ev_check check;
278 struct ev_signal signal; 286 struct ev_signal signal;
279 struct ev_child child;
280#if EV_EMBED_ENABLE 287#if EV_EMBED_ENABLE
281 struct ev_embed embed; 288 struct ev_embed embed;
282#endif
283#if EV_STAT_ENABLE
284 struct ev_stat stat;
285#endif 289#endif
286}; 290};
287 291
288/* bits for ev_default_loop and ev_loop_new */ 292/* bits for ev_default_loop and ev_loop_new */
289/* the default */ 293/* the default */
401 405
402#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) 406#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0)
403#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0) 407#define ev_timer_set(ev,after_,repeat_) do { (ev)->at = (after_); (ev)->repeat = (repeat_); } while (0)
404#define ev_periodic_set(ev,at_,ival_,res_) do { (ev)->at = (at_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0) 408#define ev_periodic_set(ev,at_,ival_,res_) do { (ev)->at = (at_); (ev)->interval = (ival_); (ev)->reschedule_cb= (res_); } while (0)
405#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0) 409#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
410#define ev_child_set(ev,pid_) do { (ev)->pid = (pid_); } while (0)
411#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0)
406#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ 412#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
407#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */ 413#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
408#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */ 414#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
409#define ev_child_set(ev,pid_) do { (ev)->pid = (pid_); } while (0)
410#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0) 415#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0)
411#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0)
412 416
413#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) 417#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
414#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0) 418#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0)
415#define ev_periodic_init(ev,cb,at,ival,res) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(at),(ival),(res)); } while (0) 419#define ev_periodic_init(ev,cb,at,ival,res) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(at),(ival),(res)); } while (0)
416#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0) 420#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
421#define ev_child_init(ev,cb,pid) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0)
422#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0)
417#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) 423#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
418#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) 424#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
419#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) 425#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
420#define ev_child_init(ev,cb,pid) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0)
421#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0) 426#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0)
422#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0)
423 427
424#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 428#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
425#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ 429#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
426 430
427#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */ 431#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */
454void ev_periodic_start (EV_P_ ev_periodic *w); 458void ev_periodic_start (EV_P_ ev_periodic *w);
455void ev_periodic_stop (EV_P_ ev_periodic *w); 459void ev_periodic_stop (EV_P_ ev_periodic *w);
456void ev_periodic_again (EV_P_ ev_periodic *w); 460void ev_periodic_again (EV_P_ ev_periodic *w);
457#endif 461#endif
458 462
459void ev_idle_start (EV_P_ ev_idle *w);
460void ev_idle_stop (EV_P_ ev_idle *w);
461
462void ev_prepare_start (EV_P_ ev_prepare *w);
463void ev_prepare_stop (EV_P_ ev_prepare *w);
464
465void ev_check_start (EV_P_ ev_check *w);
466void ev_check_stop (EV_P_ ev_check *w);
467
468/* only supported in the default loop */ 463/* only supported in the default loop */
469void ev_signal_start (EV_P_ ev_signal *w); 464void ev_signal_start (EV_P_ ev_signal *w);
470void ev_signal_stop (EV_P_ ev_signal *w); 465void ev_signal_stop (EV_P_ ev_signal *w);
471 466
472/* only supported in the default loop */ 467/* only supported in the default loop */
473void ev_child_start (EV_P_ ev_child *w); 468void ev_child_start (EV_P_ ev_child *w);
474void ev_child_stop (EV_P_ ev_child *w); 469void ev_child_stop (EV_P_ ev_child *w);
470
471# if EV_STAT_ENABLE
472void ev_stat_start (EV_P_ ev_stat *w);
473void ev_stat_stop (EV_P_ ev_stat *w);
474void ev_stat_stat (EV_P_ ev_stat *w);
475# endif
476
477void ev_idle_start (EV_P_ ev_idle *w);
478void ev_idle_stop (EV_P_ ev_idle *w);
479
480void ev_prepare_start (EV_P_ ev_prepare *w);
481void ev_prepare_stop (EV_P_ ev_prepare *w);
482
483void ev_check_start (EV_P_ ev_check *w);
484void ev_check_stop (EV_P_ ev_check *w);
475 485
476# if EV_EMBED_ENABLE 486# if EV_EMBED_ENABLE
477/* only supported when loop to be embedded is in fact embeddable */ 487/* only supported when loop to be embedded is in fact embeddable */
478void ev_embed_start (EV_P_ ev_embed *w); 488void ev_embed_start (EV_P_ ev_embed *w);
479void ev_embed_stop (EV_P_ ev_embed *w); 489void ev_embed_stop (EV_P_ ev_embed *w);
480void ev_embed_sweep (EV_P_ ev_embed *w); 490void ev_embed_sweep (EV_P_ ev_embed *w);
481# endif 491# endif
482 492
483# if EV_STAT_ENABLE
484void ev_stat_start (EV_P_ ev_stat *w);
485void ev_stat_stop (EV_P_ ev_stat *w);
486void ev_stat_stat (EV_P_ ev_stat *w);
487# endif
488
489#endif 493#endif
490 494
491#ifdef __cplusplus 495#ifdef __cplusplus
492} 496}
493#endif 497#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines