--- libev/ev.h 2009/04/15 19:35:53 1.114 +++ libev/ev.h 2009/07/09 09:11:20 1.118 @@ -82,6 +82,10 @@ # define EV_ASYNC_ENABLE 1 #endif +#ifndef EV_WALK_ENABLE +# define EV_WALK_ENABLE 0 /* not yet */ +#endif + #ifndef EV_ATOMIC_T # include # define EV_ATOMIC_T sig_atomic_t volatile @@ -185,11 +189,17 @@ * or the array index + 1 in the pendings array. */ +#if EV_MINPRI == EV_MAXPRI +# define EV_DECL_PRIORITY +#else +# define EV_DECL_PRIORITY int priority; +#endif + /* shared by all watchers */ #define EV_WATCHER(type) \ int active; /* private */ \ int pending; /* private */ \ - int priority; /* private */ \ + EV_DECL_PRIORITY /* private */ \ EV_COMMON /* rw */ \ EV_CB_DECLARE (type) /* private */ @@ -457,10 +467,8 @@ struct ev_loop *ev_loop_new (unsigned int flags); void ev_loop_destroy (EV_P); void ev_loop_fork (EV_P); -void ev_loop_verify (EV_P); ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ -void ev_now_update (EV_P); #else @@ -494,15 +502,21 @@ /* you can actually call it at any time, anywhere :) */ void ev_default_fork (void); -#if 0 +unsigned int ev_backend (EV_P); /* backend in use by loop */ +unsigned int ev_loop_count (EV_P); /* number of loop iterations */ +unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ +void ev_loop_verify (EV_P); /* abort if loop data corrupted */ + +void ev_now_update (EV_P); /* update event loop time */ +void ev_invoke_pending (EV_P); /* invoke all pending watchers */ + +#if EV_WALK_ENABLE /* walk (almost) all watchers in the loop of a given type, invoking the */ /* callback on every such watcher. The callback might stop the watcher, */ /* but do nothing else with the loop */ void ev_walk (EV_P_ int types, void (*cb)(EV_P_ int type, void *w)); #endif -unsigned int ev_backend (EV_P); /* backend in use by loop */ -unsigned int ev_loop_count (EV_P); /* number of loop iterations */ #endif /* prototypes */ #define EVLOOP_NONBLOCK 1 /* do not block/wait */ @@ -542,9 +556,9 @@ /* these may evaluate ev multiple times, and the other arguments at most once */ /* either use ev_init + ev_TYPE_set, or the ev_TYPE_init macro, below, to first initialise a watcher */ #define ev_init(ev,cb_) do { \ - ((ev_watcher *)(void *)(ev))->active = \ - ((ev_watcher *)(void *)(ev))->pending = \ - ((ev_watcher *)(void *)(ev))->priority = 0; \ + ((ev_watcher *)(void *)(ev))->active = \ + ((ev_watcher *)(void *)(ev))->pending = 0; \ + ev_set_priority ((ev), 0); \ ev_set_cb ((ev), cb_); \ } while (0) @@ -577,9 +591,15 @@ #define ev_is_pending(ev) (0 + ((ev_watcher *)(void *)(ev))->pending) /* ro, true when watcher is waiting for callback invocation */ #define ev_is_active(ev) (0 + ((ev_watcher *)(void *)(ev))->active) /* ro, true when the watcher has been started */ -#define ev_priority(ev) ((((ev_watcher *)(void *)(ev))->priority) + 0) #define ev_cb(ev) (ev)->cb /* rw */ -#define ev_set_priority(ev,pri) ((ev_watcher *)(void *)(ev))->priority = (pri) + +#if EV_MINPRI == EV_MAXPRI +# define ev_priority(ev) ((ev), EV_MINPRI) +# define ev_set_priority(ev,pri) ((ev), (pri)) +#else +# define ev_priority(ev) ((((ev_watcher *)(void *)(ev))->priority) + 0) +# define ev_set_priority(ev,pri) ( (ev_watcher *)(void *)(ev))->priority = (pri) +#endif #define ev_periodic_at(ev) (((ev_watcher_time *)(ev))->at + 0.)