summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Hübner <profan@prfn.se>2018-05-01 09:47:34 +0200
committerRobin Hübner <profan@prfn.se>2018-05-01 09:58:16 +0200
commit8cb1ff94522c8705831293eeb58017e910dcaff1 (patch)
treecb4dd63745dc49458d68b201a517dab64d1c33a6
parent9834b690aea8ecd6fb079a772df5664ff1bae618 (diff)
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 9c37b65d77..7c8dff76fe 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();
@@ -1261,6 +1265,8 @@ void OS_Windows::finalize() {
void OS_Windows::finalize_core() {
+ timeEndPeriod(1);
+
memdelete(process_map);
TCPServerWinsock::cleanup();