From 6f1188bea106d335f993729e4971770deac88619 Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Fri, 25 Nov 2005 03:12:16 +0000 Subject: [PATCH] base: fix a very theoretical performance problem --- lib/base/ebase.cpp | 5 ++++- lib/base/ebase.h | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index 7f84cc91..a3ecbc7c 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -227,6 +227,9 @@ void eMainloop::processOneEvent() /* when we not processed anything, check timers. */ if (!ret) { + /* we know that this time has passed. */ + now += poll_timeout; + singleLock s(recalcLock); /* this will never change while we have the recalcLock */ @@ -235,7 +238,7 @@ void eMainloop::processOneEvent() return; /* process all timers which are ready. first remove them out of the list. */ - while ((!m_timer_list.empty()) && (m_timer_list.begin()->getNextActivation() < now)) + while ((!m_timer_list.empty()) && (m_timer_list.begin()->getNextActivation() <= now)) m_timer_list.begin()->activate(); } } diff --git a/lib/base/ebase.h b/lib/base/ebase.h index 2a1fe628..d4709418 100644 --- a/lib/base/ebase.h +++ b/lib/base/ebase.h @@ -22,6 +22,11 @@ static inline bool operator<( const timeval &t1, const timeval &t2 ) return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); } +static inline bool operator<=( const timeval &t1, const timeval &t2 ) +{ + return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec <= t2.tv_usec); +} + static inline timeval &operator+=( timeval &t1, const timeval &t2 ) { t1.tv_sec += t2.tv_sec; -- 2.30.2