summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-05-05 06:47:13 +0200
committerGitHub <noreply@github.com>2018-05-05 06:47:13 +0200
commita53b08861ae0c53be6fa2f3eb34d216ab4d30116 (patch)
tree170b034b5ba84e61148ebd123126fc05612ab8aa
parent27e349d1619874031b48e66e398842eee7bc1ec6 (diff)
parent8cb1ff94522c8705831293eeb58017e910dcaff1 (diff)
Merge pull request #18541 from profan/fix/win-sleep
Windows: ensure minimum possible timer resolution for sleep
-rw-r--r--platform/windows/os_windows.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 363f54fc7b..bed5781ae4 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -188,6 +188,10 @@ void OS_Windows::initialize_core() {
ticks_start = 0;
ticks_start = get_ticks_usec();
+ // set minimum resolution for periodic timers, otherwise Sleep(n) may wait at least as
+ // long as the windows scheduler resolution (~16-30ms) even for calls like Sleep(1)
+ timeBeginPeriod(1);
+
process_map = memnew((Map<ProcessID, ProcessInfo>));
IP_Unix::make_default();
@@ -1252,6 +1256,8 @@ void OS_Windows::finalize() {
void OS_Windows::finalize_core() {
+ timeEndPeriod(1);
+
memdelete(process_map);
TCPServerWinsock::cleanup();