X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/9f34bd86d0dc2c2ea51fe9aa54533aa68cfadc64..6f1188bea106d335f993729e4971770deac88619:/lib/base/ebase.cpp diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index 7951f6e7..a3ecbc7c 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -59,7 +59,7 @@ void eTimer::startLongTimer( int seconds ) bActive = bSingleShot = true; interval = 0; gettimeofday(&nextActivation, 0); -// eDebug("this = %p\nnow sec = %d, usec = %d\nadd %d msec", this, nextActivation.tv_sec, nextActivation.tv_usec, msek); +// eDebug("this = %p\nnow sec = %d, usec = %d\nadd %d sec", this, nextActivation.tv_sec, nextActivation.tv_usec, seconds); if ( seconds > 0 ) nextActivation.tv_sec += seconds; // eDebug("next Activation sec = %d, usec = %d", nextActivation.tv_sec, nextActivation.tv_usec ); @@ -160,6 +160,7 @@ void eMainloop::processOneEvent() /* get current time */ timeval now; gettimeofday(&now, 0); + m_now_is_invalid = 0; int poll_timeout = -1; /* infinite in case of empty timer list */ @@ -226,10 +227,18 @@ 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 */ + /* we can savely return here, the timer will be re-checked soon. */ + if (m_now_is_invalid) + 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(); } } @@ -294,6 +303,7 @@ void eMainloop::addTimeOffset(int offset) ;it != eMainloop::existing_loops.end(); ++it) { singleLock s(it->recalcLock); + it->m_now_is_invalid = 1; for (ePtrList::iterator tit = it->m_timer_list.begin(); tit != it->m_timer_list.end(); ++tit ) tit->addTimeOffset(offset); }