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

Comparing libev/ev.h (file contents):
Revision 1.71 by root, Tue Nov 27 09:17:52 2007 UTC vs.
Revision 1.73 by root, Tue Nov 27 19:41:52 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/*****************************************************************************/
68
69#include <stddef.h> /* for size_t */
64 70
65#if EV_STAT_ENABLE 71#if EV_STAT_ENABLE
66# include <sys/stat.h> 72# include <sys/stat.h>
67#endif 73#endif
68 74
71struct ev_loop; 77struct ev_loop;
72# define EV_P struct ev_loop *loop 78# define EV_P struct ev_loop *loop
73# define EV_P_ EV_P, 79# define EV_P_ EV_P,
74# define EV_A loop 80# define EV_A loop
75# define EV_A_ EV_A, 81# define EV_A_ EV_A,
76# define EV_DEFAULT_A ev_default_loop (0) 82# define EV_DEFAULT ev_default_loop (0)
77# define EV_DEFAULT_A_ EV_DEFAULT_A, 83# define EV_DEFAULT_ EV_DEFAULT,
78#else 84#else
79# define EV_P void 85# define EV_P void
80# define EV_P_ 86# define EV_P_
81# define EV_A 87# define EV_A
82# define EV_A_ 88# define EV_A_
89# define EV_DEFAULT
83# define EV_DEFAULT_A 90# define EV_DEFAULT_
84# define EV_DEFAULT_A_
85 91
86# undef EV_EMBED_ENABLE 92# undef EV_EMBED_ENABLE
87#endif 93#endif
88 94
89/* eventmask, revents, events... */ 95/* eventmask, revents, events... */
92#define EV_READ 0x01L /* ev_io detected read will not block */ 98#define EV_READ 0x01L /* ev_io detected read will not block */
93#define EV_WRITE 0x02L /* ev_io detected write will not block */ 99#define EV_WRITE 0x02L /* ev_io detected write will not block */
94#define EV_TIMEOUT 0x00000100L /* timer timed out */ 100#define EV_TIMEOUT 0x00000100L /* timer timed out */
95#define EV_PERIODIC 0x00000200L /* periodic timer timed out */ 101#define EV_PERIODIC 0x00000200L /* periodic timer timed out */
96#define EV_SIGNAL 0x00000400L /* signal was received */ 102#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 */ 103#define EV_CHILD 0x00000800L /* child/pid had status change */
104#define EV_STAT 0x00001000L /* stat data changed */
105#define EV_IDLE 0x00002000L /* event loop is idling */
106#define EV_PREPARE 0x00004000L /* event loop about to poll */
107#define EV_CHECK 0x00008000L /* event loop finished poll */
101#define EV_EMBED 0x00008000L /* embedded event loop needs sweep */ 108#define EV_EMBED 0x00010000L /* embedded event loop needs sweep */
102#define EV_STAT 0x00010000L /* stat data changed */ 109#define EV_FORK 0x00020000L /* event loop resumed in child */
103#define EV_ERROR 0x80000000L /* sent when an error occurs */ 110#define EV_ERROR 0x80000000L /* sent when an error occurs */
104 111
105/* can be used to add custom fields to all watchers, while losing binary compatibility */ 112/* can be used to add custom fields to all watchers, while losing binary compatibility */
106#ifndef EV_COMMON 113#ifndef EV_COMMON
107# define EV_COMMON void *data; 114# define EV_COMMON void *data;
253typedef struct ev_check 260typedef struct ev_check
254{ 261{
255 EV_WATCHER (ev_check) 262 EV_WATCHER (ev_check)
256} ev_check; 263} ev_check;
257 264
265#if EV_FORK_ENABLE
266/* the callback gets invoked before check in the child process when a fork was detected */
267typedef struct ev_fork
268{
269 EV_WATCHER (ev_fork)
270} ev_fork;
271#endif
272
258#if EV_EMBED_ENABLE 273#if EV_EMBED_ENABLE
259/* used to embed an event loop inside another */ 274/* used to embed an event loop inside another */
260/* the callback gets invoked when the event loop has handled events, and can be 0 */ 275/* the callback gets invoked when the event loop has handled events, and can be 0 */
261typedef struct ev_embed 276typedef struct ev_embed
262{ 277{
274 struct ev_watcher_list wl; 289 struct ev_watcher_list wl;
275 290
276 struct ev_io io; 291 struct ev_io io;
277 struct ev_timer timer; 292 struct ev_timer timer;
278 struct ev_periodic periodic; 293 struct ev_periodic periodic;
294 struct ev_signal signal;
279 struct ev_child child; 295 struct ev_child child;
280#if EV_STAT_ENABLE 296#if EV_STAT_ENABLE
281 struct ev_stat stat; 297 struct ev_stat stat;
282#endif 298#endif
283 struct ev_idle idle; 299 struct ev_idle idle;
284 struct ev_prepare prepare; 300 struct ev_prepare prepare;
285 struct ev_check check; 301 struct ev_check check;
286 struct ev_signal signal; 302#if EV_FORK_ENABLE
303 struct ev_fork fork;
304#endif
287#if EV_EMBED_ENABLE 305#if EV_EMBED_ENABLE
288 struct ev_embed embed; 306 struct ev_embed embed;
289#endif 307#endif
290}; 308};
291 309
316 * It is used to allocate and free memory. 334 * It is used to allocate and free memory.
317 * If it returns zero when memory needs to be allocated, the library might abort 335 * If it returns zero when memory needs to be allocated, the library might abort
318 * or take some potentially destructive action. 336 * or take some potentially destructive action.
319 * The default is your system realloc function. 337 * The default is your system realloc function.
320 */ 338 */
321void ev_set_allocator (void *(*cb)(void *ptr, long size)); 339void ev_set_allocator (void *(*cb)(void *ptr, size_t size));
322 340
323/* set the callback function to call on a 341/* set the callback function to call on a
324 * retryable syscall error 342 * retryable syscall error
325 * (such as failed select, poll, epoll_wait) 343 * (such as failed select, poll, epoll_wait)
326 */ 344 */
411#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0) 429#define ev_stat_set(ev,path_,interval_) do { (ev)->path = (path_); (ev)->interval = (interval_); } while (0)
412#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */ 430#define ev_idle_set(ev) /* nop, yes, this is a serious in-joke */
413#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */ 431#define ev_prepare_set(ev) /* nop, yes, this is a serious in-joke */
414#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */ 432#define ev_check_set(ev) /* nop, yes, this is a serious in-joke */
415#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0) 433#define ev_embed_set(ev,loop_) do { (ev)->loop = (loop_); } while (0)
434#define ev_fork_set(ev) /* nop, yes, this is a serious in-joke */
416 435
417#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0) 436#define ev_io_init(ev,cb,fd,events) do { ev_init ((ev), (cb)); ev_io_set ((ev),(fd),(events)); } while (0)
418#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } while (0) 437#define ev_timer_init(ev,cb,after,repeat) do { ev_init ((ev), (cb)); ev_timer_set ((ev),(after),(repeat)); } 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) 438#define ev_periodic_init(ev,cb,at,ival,res) do { ev_init ((ev), (cb)); ev_periodic_set ((ev),(at),(ival),(res)); } while (0)
420#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0) 439#define ev_signal_init(ev,cb,signum) do { ev_init ((ev), (cb)); ev_signal_set ((ev), (signum)); } while (0)
422#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0) 441#define ev_stat_init(ev,cb,path,interval) do { ev_init ((ev), (cb)); ev_path_set ((ev),(path),(interval)); } while (0)
423#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0) 442#define ev_idle_init(ev,cb) do { ev_init ((ev), (cb)); ev_idle_set ((ev)); } while (0)
424#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0) 443#define ev_prepare_init(ev,cb) do { ev_init ((ev), (cb)); ev_prepare_set ((ev)); } while (0)
425#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0) 444#define ev_check_init(ev,cb) do { ev_init ((ev), (cb)); ev_check_set ((ev)); } while (0)
426#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0) 445#define ev_embed_init(ev,cb,loop) do { ev_init ((ev), (cb)); ev_embed_set ((ev),(loop)); } while (0)
446#define ev_fork_init(ev,cb) do { ev_init ((ev), (cb)); ev_fork_set ((ev)); } while (0)
427 447
428#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ 448#define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */
429#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ 449#define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */
430 450
431#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */ 451#define ev_priority(ev) ((ev_watcher *)(void *)(ev))->priority /* rw */
480void ev_prepare_start (EV_P_ ev_prepare *w); 500void ev_prepare_start (EV_P_ ev_prepare *w);
481void ev_prepare_stop (EV_P_ ev_prepare *w); 501void ev_prepare_stop (EV_P_ ev_prepare *w);
482 502
483void ev_check_start (EV_P_ ev_check *w); 503void ev_check_start (EV_P_ ev_check *w);
484void ev_check_stop (EV_P_ ev_check *w); 504void ev_check_stop (EV_P_ ev_check *w);
505
506# if EV_FORK_ENABLE
507void ev_fork_start (EV_P_ ev_fork *w);
508void ev_fork_stop (EV_P_ ev_fork *w);
509# endif
485 510
486# if EV_EMBED_ENABLE 511# if EV_EMBED_ENABLE
487/* only supported when loop to be embedded is in fact embeddable */ 512/* only supported when loop to be embedded is in fact embeddable */
488void ev_embed_start (EV_P_ ev_embed *w); 513void ev_embed_start (EV_P_ ev_embed *w);
489void ev_embed_stop (EV_P_ ev_embed *w); 514void ev_embed_stop (EV_P_ ev_embed *w);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines