Skip to content

Commit 53bee4e

Browse files
committed
Windows: Restrict time API use to the desktop flavor
1 parent 7759296 commit 53bee4e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

platform/windows/os_windows.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ void OS_Windows::initialize() {
281281
QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second);
282282
QueryPerformanceCounter((LARGE_INTEGER *)&ticks_start);
283283

284+
#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
284285
// set minimum resolution for periodic timers, otherwise Sleep(n) may wait at least as
285286
// long as the windows scheduler resolution (~16-30ms) even for calls like Sleep(1)
286287
TIMECAPS time_caps;
@@ -292,6 +293,9 @@ void OS_Windows::initialize() {
292293
delay_resolution = 1000;
293294
timeBeginPeriod(1);
294295
}
296+
#else
297+
delay_resolution = 1000;
298+
#endif
295299

296300
process_map = memnew((HashMap<ProcessID, ProcessInfo>));
297301

@@ -374,7 +378,9 @@ void OS_Windows::finalize_core() {
374378

375379
FileAccessWindows::finalize();
376380

381+
#if WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
377382
timeEndPeriod(1);
383+
#endif
378384

379385
memdelete(process_map);
380386
NetSocketWinSock::cleanup();

0 commit comments

Comments
 (0)