diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-02-26 20:08:56 +0200 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-06-10 14:35:30 +0300 |
commit | 48e06db2c5ed542a9b99d3716599e0be2e2fc496 (patch) | |
tree | af1a797bbcb0f9dc9be765f037e5f178b4c7a629 /src/corelib/kernel/qtimerinfo_unix.cpp | |
parent | be3dd0115b73c694496424f579408cb702dab725 (diff) |
QTimerInfoList: cleanup
- Initialize member in-class
- Remove redundant include
- Remove QTIMERINFO_DEBUG related code, it hasn't been compiled for a
long time, so it has bit-rotted, and its purpose isn't clear any more
Change-Id: I874415e1edec7c4da03f697f5f9f8665d8b015a3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qtimerinfo_unix.cpp')
-rw-r--r-- | src/corelib/kernel/qtimerinfo_unix.cpp | 76 |
1 files changed, 2 insertions, 74 deletions
diff --git a/src/corelib/kernel/qtimerinfo_unix.cpp b/src/corelib/kernel/qtimerinfo_unix.cpp index 3be88c66ef..20b34e51c8 100644 --- a/src/corelib/kernel/qtimerinfo_unix.cpp +++ b/src/corelib/kernel/qtimerinfo_unix.cpp @@ -10,11 +10,6 @@ #include "private/qobject_p.h" #include "private/qabstracteventdispatcher_p.h" -#ifdef QTIMERINFO_DEBUG -# include <QDebug> -# include <QThread> -#endif - #include <sys/times.h> using namespace std::chrono; @@ -30,10 +25,7 @@ Q_CORE_EXPORT bool qt_disable_lowpriority_timers=false; * timerBitVec array is used for keeping track of timer identifiers. */ -QTimerInfoList::QTimerInfoList() -{ - firstTimerInfo = nullptr; -} +QTimerInfoList::QTimerInfoList() = default; steady_clock::time_point QTimerInfoList::updateCurrentTime() { @@ -90,22 +82,6 @@ static constexpr seconds roundToSecs(milliseconds msecs) return secs; } -#ifdef QTIMERINFO_DEBUG -QDebug operator<<(QDebug s, timeval tv) -{ - QDebugStateSaver saver(s); - s.nospace() << tv.tv_sec << "." << qSetFieldWidth(6) << qSetPadChar(QChar(48)) << tv.tv_usec << Qt::reset; - return s; -} -QDebug operator<<(QDebug s, Qt::TimerType t) -{ - QDebugStateSaver saver(s); - s << (t == Qt::PreciseTimer ? "P" : - t == Qt::CoarseTimer ? "C" : "VC"); - return s; -} -#endif - static void calculateCoarseTimerTimeout(QTimerInfo *t, steady_clock::time_point now) { // The coarse timer works like this: @@ -230,13 +206,6 @@ static void calculateNextTimeout(QTimerInfo *t, steady_clock::time_point now) t->timeout = now; t->timeout += t->interval; } -#ifdef QTIMERINFO_DEBUG - t->expected += t->interval; - if (t->expected < currentTime) { - t->expected = currentTime; - t->expected += t->interval; - } -#endif if (t->timerType == Qt::CoarseTimer) calculateCoarseTimerTimeout(t, now); return; @@ -246,20 +215,8 @@ static void calculateNextTimeout(QTimerInfo *t, steady_clock::time_point now) t->timeout += t->interval; if (t->timeout <= now) t->timeout = time_point_cast<seconds>(now + t->interval); -#ifdef QTIMERINFO_DEBUG - t->expected.tv_sec += t->interval; - if (t->expected.tv_sec <= currentTime.tv_sec) - t->expected.tv_sec = currentTime.tv_sec + t->interval; -#endif - return; + break; } - -#ifdef QTIMERINFO_DEBUG - if (t->timerType != Qt::PreciseTimer) - qDebug() << "timer" << t->timerType << Qt::hex << t->id << Qt::dec << "interval" << t->interval - << "originally expected at" << t->expected << "will fire at" << t->timeout - << "or" << (t->timeout - t->expected) << "s late"; -#endif } bool QTimerInfoList::timerWait(timespec &tm) @@ -362,15 +319,6 @@ void QTimerInfoList::registerTimer(int timerId, milliseconds interval, } timerInsert(t); - -#ifdef QTIMERINFO_DEBUG - t->expected = expected; - t->cumulativeError = 0; - t->count = 0; - if (t->timerType != Qt::PreciseTimer) - qDebug() << "timer" << t->timerType << Qt::hex <<t->id << Qt::dec << "interval" << t->interval << "expected at" - << t->expected << "will fire first at" << t->timeout; -#endif } bool QTimerInfoList::unregisterTimer(int timerId) @@ -462,26 +410,6 @@ int QTimerInfoList::activateTimers() // remove from list removeFirst(); -#ifdef QTIMERINFO_DEBUG - float diff; - if (currentTime < currentTimerInfo->expected) { - // early - timeval early = currentTimerInfo->expected - currentTime; - diff = -(early.tv_sec + early.tv_usec / 1000000.0); - } else { - timeval late = currentTime - currentTimerInfo->expected; - diff = late.tv_sec + late.tv_usec / 1000000.0; - } - currentTimerInfo->cumulativeError += diff; - ++currentTimerInfo->count; - if (currentTimerInfo->timerType != Qt::PreciseTimer) - qDebug() << "timer" << currentTimerInfo->timerType << Qt::hex << currentTimerInfo->id << Qt::dec << "interval" - << currentTimerInfo->interval << "firing at" << currentTime - << "(orig" << currentTimerInfo->expected << "scheduled at" << currentTimerInfo->timeout - << ") off by" << diff << "activation" << currentTimerInfo->count - << "avg error" << (currentTimerInfo->cumulativeError / currentTimerInfo->count); -#endif - // determine next timeout time calculateNextTimeout(currentTimerInfo, now); |