summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2014-09-19 15:48:24 +0200
committerMichael Meeks <michael.meeks@collabora.com>2014-09-23 21:30:47 +0100
commit211b3192f05c4120fa2dd0e23988e74bdd310830 (patch)
tree344aa042f1097d7ef3021afdbf7db5846dc7a419 /tools
parent08a990fd27f5a416c2a73902792e93df7499d703 (diff)
fdo#84000: Reimplement the Windows WinSalTimer using Timer Queues.
Timer Queues http://msdn.microsoft.com/en-us/library/windows/desktop/ms686796%28v=vs.85%29.aspx allow creating & maintaing high-precision timers. This commit switches the WinSalTimer implementation from using the Timers: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644900%28v=vs.85%29.aspx to Timer Queue Timers. The 'classic' Timers do not have better precision than some 15.6ms (the documentation mentions 10ms, but some measuring seems to confirm that it is more than that). With the Timer Queue Timers, we now have 1ms precision. Incorporates some cleanup from Michael Meeks <michael.meeks@collabora.com>. Change-Id: I0312a0c9fdc2779258698b24389b24c39e643473
Diffstat (limited to 'tools')
-rw-r--r--tools/source/datetime/ttime.cxx14
1 files changed, 13 insertions, 1 deletions
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 0b147b443c33..71836e721689 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -400,7 +400,19 @@ Time Time::GetUTCOffset()
sal_uIntPtr Time::GetSystemTicks()
{
#if defined WNT
- return (sal_uIntPtr)GetTickCount();
+ static LARGE_INTEGER nTicksPerMS;
+ static bool bTicksPerMSInitialized = false;
+ if (!bTicksPerMSInitialized)
+ {
+ QueryPerformanceFrequency(&nTicksPerMS);
+ nTicksPerMS.QuadPart /= 1000;
+ bTicksPerMSInitialized = true;
+ }
+
+ LARGE_INTEGER nPerformanceCount;
+ QueryPerformanceCounter(&nPerformanceCount);
+
+ return (sal_uIntPtr)(nPerformanceCount.QuadPart/nTicksPerMS.QuadPart);
#else
timeval tv;
gettimeofday (&tv, 0);