From 60ca5695ed1d524be5dc3a8d19b3ff8ec327efe7 Mon Sep 17 00:00:00 2001 From: upstream svn Date: Sat, 7 Nov 2009 19:13:49 +0000 Subject: [PATCH] Upstream tarball 9858 --- .svn-revision | 2 +- docs/Changelog | 1 + src/Timer.cpp | 24 +++++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.svn-revision b/.svn-revision index 28d910d9..00483fb2 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -9857 +9858 diff --git a/docs/Changelog b/docs/Changelog index 2cd1092d..3fa69442 100644 --- a/docs/Changelog +++ b/docs/Changelog @@ -105,6 +105,7 @@ Version 2.3.0 - The river knows. * Fixed errors and crashes on parsing ED2K links with '/' in them * Configure option --enable-fileview * Bypass amulegui connection dialog with switch -s / --skip + * Fixed Core Timer Vollstrecker: * Unify copyright lines diff --git a/src/Timer.cpp b/src/Timer.cpp index bc117821..864241a3 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -40,20 +40,22 @@ public: void* Entry() { CTimerEvent evt(m_id); - uint64 lastEvent = GetTickCountFullRes(); + uint32 lastEvent = GetTickCountFullRes(); do { - uint64 now = GetTickCountFullRes(); - uint64 sinceLast = now - lastEvent; - if (sinceLast > 100 * m_period) { + // current time + uint32 now = GetTickCountFullRes(); + // This is typically zero, because lastEvent was already incremented by one period. + sint32 delta = now - lastEvent; + if (delta > 100 * m_period) { // We're way too far behind. Probably what really happened is - // the system time was adjusted backwards a bit, or (less - // likely) the time wrapped past the limit of a uint64. So, - // the calculation of sinceLast has produced an absurd value. - sinceLast = 100 * m_period; - lastEvent = now - sinceLast; + // the system time was adjusted backwards a bit. So, + // the calculation of delta has produced an absurd value. + delta = 100 * m_period; + lastEvent = now - delta; } - unsigned long timeout = ((m_period < sinceLast) ? 0 : (m_period - sinceLast)); + // Wait one period (adjusted by the difference just calculated) + sint32 timeout = ((m_period < delta) ? 0 : (m_period - delta)); // In normal operation, we will never actually acquire the // semaphore; we will always timeout. This is used to @@ -74,7 +76,7 @@ public: return NULL; } - unsigned long m_period; + sint32 m_period; bool m_oneShot; wxEvtHandler* m_owner; int m_id; -- 2.11.4.GIT