Increase accuracy of Windows Sleep function
Windows 10 version 1803 (build 17134) and later versions support high-resolution waitable timer, which offers much better accuracy over Sleep function without the need of increasing the global timer resolution. For older versions of Windows, we reduce the timer resolution to 1ms and use normal waitable timer for sleeping.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "../Win32/IncludeWindowsHeaders.h"
|
||||
#include <VersionHelpers.h>
|
||||
#include <ShellAPI.h>
|
||||
#include <timeapi.h>
|
||||
#include <Psapi.h>
|
||||
#include <objbase.h>
|
||||
#if CRASH_LOG_ENABLE
|
||||
@@ -579,6 +580,12 @@ bool WindowsPlatform::Init()
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set lowest possible timer resolution for previous Windows versions
|
||||
if (VersionMajor < 10 || (VersionMajor == 10 && VersionBuild < 17134))
|
||||
{
|
||||
timeBeginPeriod(1);
|
||||
}
|
||||
|
||||
DWORD tmp;
|
||||
Char buffer[256];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user