Deprecate QElapsedTimer::TickCounter
Also remove left-over code paths related to it. [ChangeLog][QtCore] QElapsedTimer::TickCounter enum is now deprecated. Qt does not use the Windows API behind this enum already since Qt 5.9, so it's fair to assume that any code path relying on the enum is dead code. Change-Id: I308fe23658835034774e2015a8ee64659102de56 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
aaa3184f8d
commit
7d5604c194
@ -51,7 +51,8 @@ public:
|
|||||||
enum ClockType {
|
enum ClockType {
|
||||||
SystemTime,
|
SystemTime,
|
||||||
MonotonicClock,
|
MonotonicClock,
|
||||||
TickCounter,
|
TickCounter Q_DECL_ENUMERATOR_DEPRECATED_X(
|
||||||
|
"Not supported anymore. Use PerformanceCounter instead."),
|
||||||
MachAbsoluteTime,
|
MachAbsoluteTime,
|
||||||
PerformanceCounter
|
PerformanceCounter
|
||||||
};
|
};
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
// Result of QueryPerformanceFrequency, 0 indicates that the high resolution timer is unavailable
|
// Result of QueryPerformanceFrequency
|
||||||
static quint64 counterFrequency = 0;
|
static quint64 counterFrequency = 0;
|
||||||
|
|
||||||
static void resolveCounterFrequency()
|
static void resolveCounterFrequency()
|
||||||
@ -55,26 +55,19 @@ static void resolveCounterFrequency()
|
|||||||
|
|
||||||
// Retrieve the number of high-resolution performance counter ticks per second
|
// Retrieve the number of high-resolution performance counter ticks per second
|
||||||
LARGE_INTEGER frequency;
|
LARGE_INTEGER frequency;
|
||||||
if (!QueryPerformanceFrequency(&frequency)) {
|
if (!QueryPerformanceFrequency(&frequency) || frequency.QuadPart == 0)
|
||||||
qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
|
qFatal("QueryPerformanceFrequency failed, even though Microsoft documentation promises it wouldn't.");
|
||||||
counterFrequency = 0;
|
counterFrequency = frequency.QuadPart;
|
||||||
} else {
|
|
||||||
counterFrequency = frequency.QuadPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline qint64 ticksToNanoseconds(qint64 ticks)
|
static inline qint64 ticksToNanoseconds(qint64 ticks)
|
||||||
{
|
{
|
||||||
if (counterFrequency > 0) {
|
// QueryPerformanceCounter uses an arbitrary frequency
|
||||||
// QueryPerformanceCounter uses an arbitrary frequency
|
qint64 seconds = ticks / counterFrequency;
|
||||||
qint64 seconds = ticks / counterFrequency;
|
qint64 nanoSeconds = (ticks - seconds * counterFrequency) * 1000000000 / counterFrequency;
|
||||||
qint64 nanoSeconds = (ticks - seconds * counterFrequency) * 1000000000 / counterFrequency;
|
return seconds * 1000000000 + nanoSeconds;
|
||||||
return seconds * 1000000000 + nanoSeconds;
|
|
||||||
}
|
|
||||||
// GetTickCount(64) returns milliseconds
|
|
||||||
return ticks * 1000000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -82,18 +75,12 @@ static quint64 getTickCount()
|
|||||||
{
|
{
|
||||||
resolveCounterFrequency();
|
resolveCounterFrequency();
|
||||||
|
|
||||||
// This avoids a division by zero and disables the high performance counter if it's not available
|
LARGE_INTEGER counter;
|
||||||
if (counterFrequency > 0) {
|
bool ok = QueryPerformanceCounter(&counter);
|
||||||
LARGE_INTEGER counter;
|
Q_ASSERT_X(ok, "QElapsedTimer::start()",
|
||||||
|
"QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
|
||||||
bool ok = QueryPerformanceCounter(&counter);
|
Q_UNUSED(ok);
|
||||||
Q_ASSERT_X(ok, "QElapsedTimer::start()",
|
return counter.QuadPart;
|
||||||
"QueryPerformanceCounter failed, although QueryPerformanceFrequency succeeded.");
|
|
||||||
Q_UNUSED(ok);
|
|
||||||
return counter.QuadPart;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetTickCount64();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 qt_msectime()
|
quint64 qt_msectime()
|
||||||
@ -105,7 +92,7 @@ QElapsedTimer::ClockType QElapsedTimer::clockType() noexcept
|
|||||||
{
|
{
|
||||||
resolveCounterFrequency();
|
resolveCounterFrequency();
|
||||||
|
|
||||||
return counterFrequency > 0 ? PerformanceCounter : TickCounter;
|
return PerformanceCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QElapsedTimer::isMonotonic() noexcept
|
bool QElapsedTimer::isMonotonic() noexcept
|
||||||
|
Loading…
x
Reference in New Issue
Block a user