summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot <root>2007-11-11 02:26:47 +0000
committerroot <root>2007-11-11 02:26:47 +0000
commit4f1dc6c0e6bd6e6e6edab0e55fc6b96824a12f38 (patch)
tree700c5667c21895ac6f4403c92c6f7928382b65ef
parent18894ffdcf36dd48598363b9551cc04b1168b3ee (diff)
fix moa bugs, change the way adjustheap is being used, make it work with multiplicity again
-rw-r--r--ev.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/ev.c b/ev.c
index 3e008a4..299ba00 100644
--- a/ev.c
+++ b/ev.c
@@ -235,6 +235,7 @@ typedef struct
struct ev_loop
{
ev_tstamp ev_rt_now;
+ #define ev_rt_now ((loop)->ev_rt_now)
#define VAR(name,decl) decl;
#include "ev_vars.h"
#undef VAR
@@ -536,15 +537,10 @@ downheap (WT *heap, int N, int k)
}
inline void
-adjustheap (WT *heap, int N, int k, ev_tstamp at)
+adjustheap (WT *heap, int N, int k)
{
- ev_tstamp old_at = heap [k]->at;
- heap [k]->at = at;
-
- if (old_at < at)
- downheap (heap, N, k);
- else
- upheap (heap, k);
+ upheap (heap, k);
+ downheap (heap, N, k);
}
/*****************************************************************************/
@@ -1354,7 +1350,7 @@ ev_timer_stop (EV_P_ struct ev_timer *w)
if (((W)w)->active < timercnt--)
{
timers [((W)w)->active - 1] = timers [timercnt];
- downheap ((WT *)timers, timercnt, ((W)w)->active - 1);
+ adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
}
((WT)w)->at -= mn_now;
@@ -1368,7 +1364,10 @@ ev_timer_again (EV_P_ struct ev_timer *w)
if (ev_is_active (w))
{
if (w->repeat)
- adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1, mn_now + w->repeat);
+ {
+ ((WT)w)->at = mn_now + w->repeat;
+ adjustheap ((WT *)timers, timercnt, ((W)w)->active - 1);
+ }
else
ev_timer_stop (EV_A_ w);
}
@@ -1412,7 +1411,7 @@ ev_periodic_stop (EV_P_ struct ev_periodic *w)
if (((W)w)->active < periodiccnt--)
{
periodics [((W)w)->active - 1] = periodics [periodiccnt];
- downheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1);
+ adjustheap ((WT *)periodics, periodiccnt, ((W)w)->active - 1);
}
ev_stop (EV_A_ (W)w);