summaryrefslogtreecommitdiff
path: root/utils/Timer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'utils/Timer.cc')
-rw-r--r--utils/Timer.cc20
1 files changed, 17 insertions, 3 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;
}
/*?