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

Comparing libev/ev.h (file contents):
Revision 1.70 by root, Tue Nov 27 08:11:52 2007 UTC vs.
Revision 1.72 by root, Tue Nov 27 10:59:11 2007 UTC

54 54
55#ifndef EV_STAT_ENABLE 55#ifndef EV_STAT_ENABLE
56# define EV_STAT_ENABLE 1 56# define EV_STAT_ENABLE 1
57#endif 57#endif
58 58
59#ifndef EV_FORK_ENABLE
60# define EV_FORK_ENABLE 1
61#endif
62
59#ifndef EV_EMBED_ENABLE 63#ifndef EV_EMBED_ENABLE
60# define EV_EMBED_ENABLE 1 64# define EV_EMBED_ENABLE 1
61#endif 65#endif
62 66
63/*****************************************************************************/ 67/*****************************************************************************/
71struct ev_loop; 75struct ev_loop;
72# define EV_P struct ev_loop *loop 76# define EV_P struct ev_loop *loop
73# define EV_P_ EV_P, 77# define EV_P_ EV_P,
74# define EV_A loop 78# define EV_A loop
75# define EV_A_ EV_A, 79# define EV_A_ EV_A,
76# define EV_DEFAULT_A ev_default_loop (0) 80# define EV_DEFAULT ev_default_loop (0)
77# define EV_DEFAULT_A_ EV_DEFAULT_A, 81# define EV_DEFAULT_ EV_DEFAULT,
78#else 82#else
79# define EV_P void 83# define EV_P void
80# define EV_P_ 84# define EV_P_
81# define EV_A 85# define EV_A
82# define EV_A_ 86# define EV_A_
87# define EV_DEFAULT
83# define EV_DEFAULT_A 88# define EV_DEFAULT_
84# define EV_DEFAULT_A_
85 89
86# undef EV_EMBED_ENABLE 90# undef EV_EMBED_ENABLE
87#endif 91#endif
88 92
89/* eventmask, revents, events... */ 93/* eventmask, revents, events... */
92#define EV_READ 0x01L /* ev_io detected read will not block */ 96#define EV_READ 0x01L /* ev_io detected read will not block */
93#define EV_WRITE 0x02L /* ev_io detected write will not block */ 97#define EV_WRITE 0x02L /* ev_io detected write will not block */
94#define EV_TIMEOUT 0x00000100L /* timer timed out */ 98#define EV_TIMEOUT 0x00000100L /* timer timed out */
95#define EV_PERIODIC 0x00000200L /* periodic timer timed out */ 99#define EV_PERIODIC 0x00000200L /* periodic timer timed out */
96#define EV_SIGNAL 0x00000400L /* signal was received */ 100#define EV_SIGNAL 0x00000400L /* signal was received */
97#define EV_IDLE 0x00000800L /* event loop is idling */
98#define EV_PREPARE 0x00001000L /* event loop about to poll */
99#define EV_CHECK 0x00002000L /* event loop finished poll */
100#define EV_CHILD 0x00004000L /* child/pid had status change */ 101#define EV_CHILD 0x00000800L /* child/pid had status change */
102#define EV_STAT 0x00001000L /* stat data changed */
103#define EV_IDLE 0x00002000L /* event loop is idling */
104#define EV_PREPARE 0x00004000L /* event loop about to poll */
105#define EV_CHECK 0x00008000L /* event loop finished poll */
101#define EV_EMBED 0x00008000L /* embedded event loop needs sweep */ 106#define EV_EMBED 0x00010000L /* embedded event loop needs sweep */
102#define EV_STAT 0x00010000L /* stat data changed */ 107#define EV_FORK 0x00020000L /* event loop resumed in child */
103#define EV_ERROR 0x80000000L /* sent when an error occurs */ 108#define EV_ERROR 0x80000000L /* sent when an error occurs */
104 109
105/* can be used to add custom fields to all watchers, while losing binary compatibility */ 110/* can be used to add custom fields to all watchers, while losing binary compatibility */
106#ifndef EV_COMMON 111#ifndef EV_COMMON
107# define EV_COMMON void *data; 112# define EV_COMMON void *data;
211 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 */
212} ev_child; 217} ev_child;
213 218
214#if EV_STAT_ENABLE 219#if EV_STAT_ENABLE
215/* st_nlink = 0 means missing file or other error */ 220/* st_nlink = 0 means missing file or other error */
221#ifdef _WIN32
222typedef struct _stati64 ev_statdata;
223#else
216typedef struct stat ev_statdata; 224typedef struct stat ev_statdata;
225#endif
217 226
218/* invoked each time the stat data changes for a given path */ 227/* invoked each time the stat data changes for a given path */
219/* revent EV_STAT */ 228/* revent EV_STAT */
220typedef struct ev_stat 229typedef struct ev_stat
221{ 230{
249typedef struct ev_check 258typedef struct ev_check
250{ 259{
251 EV_WATCHER (ev_check) 260 EV_WATCHER (ev_check)
252} ev_check; 261} ev_check;
253 262
263#if EV_FORK_ENABLE
264/* the callback gets invoked before check in the child process when a fork was detected */
265typedef struct ev_fork
266{
267 EV_WATCHER (ev_fork)
268} ev_fork;
269#endif
270
254#if EV_EMBED_ENABLE 271#if EV_EMBED_ENABLE
255/* used to embed an event loop inside another */ 272/* used to embed an event loop inside another */
256/* the callback gets invoked when the event loop has handled events, and can be 0 */ 273/* the callback gets invoked when the event loop has handled events, and can be 0 */
257typedef struct ev_embed 274typedef struct ev_embed
258{ 275{
270 struct ev_watcher_list wl; 287 struct ev_watcher_list wl;
271 288
272 struct ev_io io; 289 struct ev_io io;
273 struct ev_timer timer; 290 struct ev_timer timer;
274 struct ev_periodic periodic; 291 struct ev_periodic periodic;
292 struct ev_signal signal;
275 struct ev_child child; 293 struct ev_child child;
276#if EV_STAT_ENABLE 294#if EV_STAT_ENABLE
277 struct ev_stat stat; 295 struct ev_stat stat;
278#endif 296#endif
279 struct ev_idle idle; 297 struct ev_idle idle;
280 struct ev_prepare prepare; 298 struct ev_prepare prepare;
281 struct ev_check check; 299 struct ev_check check;
282 struct ev_signal signal; 300#if EV_FORK_ENABLE
301 struct ev_fork fork;
302#endif
283#if EV_EMBED_ENABLE 303#if EV_EMBED_ENABLE
284 struct ev_embed embed; 304 struct ev_embed embed;
285#endif 305#endif
286}; 306};
287 307
407#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0) 427#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0)
408#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ 428#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
409#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */ 429#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
410#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */ 430#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
411#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0) 431#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0)
432#define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
412 433
413#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) 434#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) 435#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) 436#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) 437#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
418#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0) 439#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0)
419#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) 440#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
420#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) 441#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
421#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) 442#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
422#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0) 443#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0)
444#define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
423 445
424#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 446#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 */ 447#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
426 448
427#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */ 449#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */
476void ev_prepare_start (EV_P_ ev_prepare *w); 498void ev_prepare_start (EV_P_ ev_prepare *w);
477void ev_prepare_stop (EV_P_ ev_prepare *w); 499void ev_prepare_stop (EV_P_ ev_prepare *w);
478 500
479void ev_check_start (EV_P_ ev_check *w); 501void ev_check_start (EV_P_ ev_check *w);
480void ev_check_stop (EV_P_ ev_check *w); 502void ev_check_stop (EV_P_ ev_check *w);
503
504# if EV_FORK_ENABLE
505void ev_fork_start (EV_P_ ev_fork *w);
506void ev_fork_stop (EV_P_ ev_fork *w);
507# endif
481 508
482# if EV_EMBED_ENABLE 509# if EV_EMBED_ENABLE
483/* only supported when loop to be embedded is in fact embeddable */ 510/* only supported when loop to be embedded is in fact embeddable */
484void ev_embed_start (EV_P_ ev_embed *w); 511void ev_embed_start (EV_P_ ev_embed *w);
485void ev_embed_stop (EV_P_ ev_embed *w); 512void ev_embed_stop (EV_P_ ev_embed *w);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines