summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2009-07-08 04:29:31 +0000
committerroot <root>2009-07-08 04:29:31 +0000
commitdcdb154c9c5bd4ae64d5ebde7392ce11d7c774aa (patch)
tree01e2962ef6a7271a13c650c5e331c83daff7edcb
parentaf092237b3f7c591a942a155282f81a058627c8a (diff)
*** empty log message ***
-rw-r--r--Changes1
-rw-r--r--ev.c13
-rw-r--r--ev.h24
-rw-r--r--ev.pod3
4 files changed, 30 insertions, 11 deletions
diff --git a/Changes b/Changes
index 0adecb6..fed3214 100644
--- a/Changes
+++ b/Changes
@@ -13,6 +13,7 @@ TODO: remain
slightly higher accuracy.
- properly declare ev_loop_verify even when !EV_MULTIPLICITY.
- implement ev_loop_depth.
+ - do not compile in any priority code when EV_MAXPRI == EV_MINPRI.
3.6 Tue Apr 28 02:49:30 CEST 2009
- multiple timers becoming ready within an event loop iteration
diff --git a/ev.c b/ev.c
index d6c28c7..421ef28 100644
--- a/ev.c
+++ b/ev.c
@@ -393,8 +393,13 @@ int eventfd (unsigned int initval, int flags);
# define inline_speed static inline
#endif
-#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
-#define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
+#define NUMPRI (EV_MAXPRI - EV_MINPRI + 1)
+
+#if EV_MINPRI == EV_MAXPRI
+# define ABSPRI(w) (((W)w), 0)
+#else
+# define ABSPRI(w) (((W)w)->priority - EV_MINPRI)
+#endif
#define EMPTY /* required for microsofts broken pseudo-c compiler */
#define EMPTY2(a,b) /* used to suppress some warnings */
@@ -2260,10 +2265,10 @@ ev_clear_pending (EV_P_ void *w)
inline_size void
pri_adjust (EV_P_ W w)
{
- int pri = w->priority;
+ int pri = ev_priority (w);
pri = pri < EV_MINPRI ? EV_MINPRI : pri;
pri = pri > EV_MAXPRI ? EV_MAXPRI : pri;
- w->priority = pri;
+ ev_set_priority (w, pri);
}
inline_speed void
diff --git a/ev.h b/ev.h
index 0af57a2..52ed6cf 100644
--- a/ev.h
+++ b/ev.h
@@ -189,11 +189,17 @@ struct ev_loop;
* 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 */
@@ -548,9 +554,9 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
/* 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)
@@ -583,9 +589,15 @@ void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revent
#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.)
diff --git a/ev.pod b/ev.pod
index e90161f..df435ca 100644
--- a/ev.pod
+++ b/ev.pod
@@ -2035,7 +2035,8 @@ Only the default event loop is capable of handling signals, and therefore
you can only register child watchers in the default event loop.
Due to some design glitches inside libev, child watchers will always be
-handled at maximum priority (their priority is set to EV_MAXPRI by libev)
+handled at maximum priority (their priority is set to C<EV_MAXPRI> by
+libev)
=head3 Process Interaction