summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorchatty2000-11-28 14:19:34 +0000
committerchatty2000-11-28 14:19:34 +0000
commit7f84f875dd5343a4ae60ac39d1666527adf90f85 (patch)
tree0d9ae2286a40d37af81c025ee6989cc1c74a371d /utils
parent09f57c8dffd9a8ba0983cce13381aef716f43801 (diff)
downloadivy-league-7f84f875dd5343a4ae60ac39d1666527adf90f85.zip
ivy-league-7f84f875dd5343a4ae60ac39d1666527adf90f85.tar.gz
ivy-league-7f84f875dd5343a4ae60ac39d1666527adf90f85.tar.bz2
ivy-league-7f84f875dd5343a4ae60ac39d1666527adf90f85.tar.xz
Fixed nasty bug triggered when calling Restart in Handle: added FirstIsUpdated
Diffstat (limited to 'utils')
-rw-r--r--utils/Timer.cc20
-rw-r--r--utils/Timer.h7
2 files changed, 21 insertions, 6 deletions
diff --git a/utils/Timer.cc b/utils/Timer.cc
index 91e97d0..8342854 100644
--- a/utils/Timer.cc
+++ b/utils/Timer.cc
@@ -3,7 +3,7 @@
*
* by Stephane Chatty
*
- * Copyright 1992-1995
+ * Copyright 1992-1996
* Centre d'Etudes de la Navigation Aerienne (CENA)
*
* timers
@@ -105,6 +105,7 @@ CcuTimerSet :: ExtractNextActive ()
while ((t = (CcuCoreTimer*) OtherTimers.RemoveFirst ()) && (t->StatusFlag != CcuCoreTimer::Active))
#endif
;
+
return t;
}
@@ -144,20 +145,31 @@ CcuCoreTimer :: Fire (CcuTimerSet* s)
return;
}
- /* Handle the first timer */
+ /**** Handle the first timer ****/
+ /* first, reschedule it ASAP*/
first->Reschedule ();
+ /* first is not valid, but Handle will perhaps call Stop or Restart and do the job */
+ s->FirstIsUpdated = false;
+ /* then, call the user's code */
first->Handle (now);
/* handle all other expired timers. */
CcuCoreTimer* t;
while (t = s->ExtractNextActive ()) {
/* Problem : if one Handle () is long, "now" will then be wrong. */
- if (t->NextDate > now)
+ if (t->NextDate > now) {
+// fprintf (stderr, "%x is not ready\n", t);
break;
+ }
+// fprintf (stderr, "%x is ready\n", t);
t->Reschedule ();
t->Handle (now);
}
+ /* don't try and update first if it's alredy been done! */
+ if (s->FirstIsUpdated)
+ return;
+
if (t) {
CcuTimeStamp then;
t->SetAlarm (t->NextDate - then);
@@ -280,6 +292,7 @@ CcuCoreTimer :: Activate ()
} else
Schedule (NextDate);
StatusFlag = Active;
+ MySet->FirstIsUpdated = true;
}
/*?hidden?*/
@@ -359,6 +372,7 @@ CcuCoreTimer :: Stop ()
first->SetAlarm (first->NextDate - now);
}
}
+ MySet->FirstIsUpdated = true;
}
/*?
diff --git a/utils/Timer.h b/utils/Timer.h
index 367a320..bdeb520 100644
--- a/utils/Timer.h
+++ b/utils/Timer.h
@@ -3,7 +3,7 @@
*
* by Stephane Chatty
*
- * Copyright 1992-1995
+ * Copyright 1992-1996
* Centre d'Etudes de la Navigation Aerienne (CENA)
*
* timers
@@ -38,11 +38,12 @@ private:
#else
CcuList OtherTimers;
#endif
+ bool FirstIsUpdated;
CcuCoreTimer* ExtractNextActive ();
public:
-inline CcuTimerSet () : FirstTimer (0), OtherTimers () {}
+inline CcuTimerSet () : FirstTimer (0), OtherTimers (), FirstIsUpdated (false) {}
inline ~CcuTimerSet () {}
-inline bool IsEmpty () const { return bool (FirstTimer == 0); }
+//inline bool IsEmpty () const { return bool (FirstTimer == 0); } seems useless (10 may 96)
};
class CcuCoreTimer {