double nextProfile = 0;
#endif /* _DEBUG */
+ double lastLoop = Utility::GetTime();
+
while (!m_ShuttingDown) {
Object::ClearHeldObjects();
nextProfile = Utility::GetTime() + 15.0;
}
#endif /* _DEBUG */
+
+ double now = Utility::GetTime();
+
+ if (now < lastLoop) {
+ /* We moved backwards in time - cool. */
+ double lostTime = lastLoop - now;
+ stringstream msgbuf;
+ msgbuf << "We moved backwards in time: " << lostTime
+ << " seconds";
+ Logger::Write(LogInformation, "base", msgbuf.str());
+ Timer::AdjustTimers(-lostTime);
+ }
+
+ lastLoop = now;
}
}
{
m_Next = next;
}
+
+/**
+ * Adjusts all timers by adding the specified amount of time to their
+ * next scheduled timestamp.
+ *
+ * @param adjustment The adjustment.
+ */
+void Timer::AdjustTimers(double adjustment)
+{
+ BOOST_FOREACH(Timer::Ptr timer, m_Timers) {
+ timer->m_Next += adjustment;
+ }
+}
double GetInterval(void) const;
static double ProcessTimers(void);
+ static void AdjustTimers(double adjustment);
void Start(void);
void Stop(void);