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.70 by root, Tue Nov 27 08:11: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 */
216typedef struct stat ev_statdata;
217
218/* invoked each time the stat data changes for a given path */
219/* revent EV_STAT */
220typedef struct ev_stat
221{
222 EV_WATCHER (ev_stat)
223
224 ev_timer timer; /* private */
225 ev_tstamp interval; /* ro */
226 const char *path; /* ro */
227 ev_statdata prev; /* ro */
228 ev_statdata attr; /* ro */
229} ev_stat;
230#endif
201 231
202/* invoked when the nothing else needs to be done, keeps the process from blocking */ 232/* invoked when the nothing else needs to be done, keeps the process from blocking */
203/* revent EV_IDLE */ 233/* revent EV_IDLE */
204typedef struct ev_idle 234typedef struct ev_idle
205{ 235{
219typedef struct ev_check 249typedef struct ev_check
220{ 250{
221 EV_WATCHER (ev_check) 251 EV_WATCHER (ev_check)
222} ev_check; 252} ev_check;
223 253
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 254#if EV_EMBED_ENABLE
237/* used to embed an event loop inside another */ 255/* used to embed an event loop inside another */
238/* the callback gets invoked when the event loop has handled events, and can be 0 */ 256/* the callback gets invoked when the event loop has handled events, and can be 0 */
239typedef struct ev_embed 257typedef struct ev_embed
240{ 258{
243 ev_io io; /* private */ 261 ev_io io; /* private */
244 struct ev_loop *loop; /* ro */ 262 struct ev_loop *loop; /* ro */
245} ev_embed; 263} ev_embed;
246#endif 264#endif
247 265
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 */ 266/* the presence of this union forces similar struct layout */
267union ev_any_watcher 267union ev_any_watcher
268{ 268{
269 struct ev_watcher w; 269 struct ev_watcher w;
270 struct ev_watcher_list wl; 270 struct ev_watcher_list wl;
271 271
272 struct ev_io io; 272 struct ev_io io;
273 struct ev_timer timer; 273 struct ev_timer timer;
274 struct ev_periodic periodic; 274 struct ev_periodic periodic;
275 struct ev_child child;
276#if EV_STAT_ENABLE
277 struct ev_stat stat;
278#endif
275 struct ev_idle idle; 279 struct ev_idle idle;
276 struct ev_prepare prepare; 280 struct ev_prepare prepare;
277 struct ev_check check; 281 struct ev_check check;
278 struct ev_signal signal; 282 struct ev_signal signal;
279 struct ev_child child;
280#if EV_EMBED_ENABLE 283#if EV_EMBED_ENABLE
281 struct ev_embed embed; 284 struct ev_embed embed;
282#endif
283#if EV_STAT_ENABLE
284 struct ev_stat stat;
285#endif 285#endif
286}; 286};
287 287
288/* bits for ev_default_loop and ev_loop_new */ 288/* bits for ev_default_loop and ev_loop_new */
289/* the default */ 289/* the default */
401 401
402#define ev_io_set(ev,fd_,events_) do { (ev)->fd = (fd_); (ev)->events = (events_); } while (0) 402#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) 403#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) 404#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) 405#define ev_signal_set(ev,signum_) do { (ev)->signum = (signum_); } while (0)
406#define ev_child_set(ev,pid_) do { (ev)->pid = (pid_); } while (0)
407#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 */ 408#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 */ 409#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 */ 410#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) 411#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 412
413#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) 413#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) 414#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) 415#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) 416#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
417#define ev_child_init(ev,cb,pid) do { ev_init ((ev), (cb)); ev_child_set ((ev),(pid)); } while (0)
418#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) 419#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) 420#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) 421#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) 422#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 423
424#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 424#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 */ 425#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
426 426
427#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */ 427#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */
454void ev_periodic_start (EV_P_ ev_periodic *w); 454void ev_periodic_start (EV_P_ ev_periodic *w);
455void ev_periodic_stop (EV_P_ ev_periodic *w); 455void ev_periodic_stop (EV_P_ ev_periodic *w);
456void ev_periodic_again (EV_P_ ev_periodic *w); 456void ev_periodic_again (EV_P_ ev_periodic *w);
457#endif 457#endif
458 458
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 */ 459/* only supported in the default loop */
469void ev_signal_start (EV_P_ ev_signal *w); 460void ev_signal_start (EV_P_ ev_signal *w);
470void ev_signal_stop (EV_P_ ev_signal *w); 461void ev_signal_stop (EV_P_ ev_signal *w);
471 462
472/* only supported in the default loop */ 463/* only supported in the default loop */
473void ev_child_start (EV_P_ ev_child *w); 464void ev_child_start (EV_P_ ev_child *w);
474void ev_child_stop (EV_P_ ev_child *w); 465void ev_child_stop (EV_P_ ev_child *w);
466
467# if EV_STAT_ENABLE
468void ev_stat_start (EV_P_ ev_stat *w);
469void ev_stat_stop (EV_P_ ev_stat *w);
470void ev_stat_stat (EV_P_ ev_stat *w);
471# endif
472
473void ev_idle_start (EV_P_ ev_idle *w);
474void ev_idle_stop (EV_P_ ev_idle *w);
475
476void ev_prepare_start (EV_P_ ev_prepare *w);
477void ev_prepare_stop (EV_P_ ev_prepare *w);
478
479void ev_check_start (EV_P_ ev_check *w);
480void ev_check_stop (EV_P_ ev_check *w);
475 481
476# if EV_EMBED_ENABLE 482# if EV_EMBED_ENABLE
477/* only supported when loop to be embedded is in fact embeddable */ 483/* only supported when loop to be embedded is in fact embeddable */
478void ev_embed_start (EV_P_ ev_embed *w); 484void ev_embed_start (EV_P_ ev_embed *w);
479void ev_embed_stop (EV_P_ ev_embed *w); 485void ev_embed_stop (EV_P_ ev_embed *w);
480void ev_embed_sweep (EV_P_ ev_embed *w); 486void ev_embed_sweep (EV_P_ ev_embed *w);
481# endif 487# endif
482 488
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 489#endif
490 490
491#ifdef __cplusplus 491#ifdef __cplusplus
492} 492}
493#endif 493#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines