diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-12-21 11:34:07 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-05 22:15:25 +0100 |
commit | c46654b3a5deb92f5ac2ce41be9d7a302dd04db5 (patch) | |
tree | 8d3ae1a1f1a70bddb54ffe7be934e386bb5def9e /src/corelib/kernel/qtimerinfo_unix_p.h | |
parent | c355c300d92666c82c2f66c493329c783b8b9811 (diff) |
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 <thiago.macieira@nokia.com>
Change-Id: Iaa70314c39a446adbc6dbb6fdfa7bafcd98a7283
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qtimerinfo_unix_p.h')
-rw-r--r-- | src/corelib/kernel/qtimerinfo_unix_p.h | 10 |
1 files changed, 9 insertions, 1 deletions
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 <sys/time.h> // 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<QTimerInfo*> |