Call timeBeginPeriod only once on startup (#6273)

Use SetProcessInformation to make the OS better handle our threads on big/small cores
This commit is contained in:
Cacodemon345
2025-10-04 02:03:11 +06:00
committed by GitHub
parent da018531e0
commit 37edcce1fa
3 changed files with 77 additions and 14 deletions

View File

@@ -98,6 +98,7 @@ extern "C" {
#include <86box/timer.h>
#include <86box/nvr.h>
extern int qt_nvr_save(void);
extern void exit_pause(void);
bool cpu_thread_running = false;
}
@@ -753,6 +754,14 @@ main(int argc, char *argv[])
discord_load();
#endif
#ifdef Q_OS_WINDOWS
// On Win32 the accuracy of Sleep() depends on the timer resolution, which can be set by calling timeBeginPeriod
// https://learn.microsoft.com/en-us/windows/win32/api/timeapi/nf-timeapi-timebeginperiod
exit_pause();
timeBeginPeriod(1);
atexit([] () -> void { timeEndPeriod(1); });
#endif
main_window = new MainWindow();
if (startMaximized) {
main_window->showMaximized();