From c46654b3a5deb92f5ac2ce41be9d7a302dd04db5 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Dec 2011 11:34:07 +0100 Subject: Use Qt::TimerType on UNIX when scheduling timers As stated in the documentation for Qt::TimerType, we allow for up to 5% error for CoarseTimers (the default timer type). PreciseTimers are not adjusted at all, and VeryCoarseTimers fire with one-second accuracy. The objective is to make most timers wake up at the same time, thereby reducing CPU wakeups. Note that this changes makes it possible for timers to fire early, which may be unexpected for some applications. Such applications should use PreciseTimers explicitly. Author: Thiago Macieira Change-Id: Iaa70314c39a446adbc6dbb6fdfa7bafcd98a7283 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qtimerinfo_unix_p.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qtimerinfo_unix_p.h') diff --git a/src/corelib/kernel/qtimerinfo_unix_p.h b/src/corelib/kernel/qtimerinfo_unix_p.h index cff02b6da8..c397703f58 100644 --- a/src/corelib/kernel/qtimerinfo_unix_p.h +++ b/src/corelib/kernel/qtimerinfo_unix_p.h @@ -53,6 +53,8 @@ // We mean it. // +// #define QTIMERINFO_DEBUG + #include "qabstracteventdispatcher.h" #include // struct timeval @@ -64,9 +66,15 @@ struct QTimerInfo { int id; // - timer identifier int interval; // - timer interval in milliseconds Qt::TimerType timerType; // - timer type - timeval timeout; // - when to sent event + timeval expected; // when timer is expected to fire + timeval timeout; // - when to actually fire QObject *obj; // - object to receive event QTimerInfo **activateRef; // - ref from activateTimers + +#ifdef QTIMERINFO_DEBUG + float cumulativeError; + uint count; +#endif }; class QTimerInfoList : public QList -- cgit v1.2.3