[MISC] Allow user to override process priority class

This commit is contained in:
Xphalnos
2024-10-25 20:03:20 +02:00
committed by Radosław Gliński
parent 82cb261140
commit cf0ee05da6
5 changed files with 35 additions and 0 deletions

View File

@@ -7,6 +7,7 @@
******************************************************************************
*/
#include <map>
#include "xenia/base/platform_win.h"
#include "xenia/base/string.h"
#include "xenia/base/system.h"
@@ -48,4 +49,19 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type,
type_flags);
}
static std::map<const uint32_t, DWORD> xeniaToWindowsPriorityClassMapping = {
{0, NORMAL_PRIORITY_CLASS},
{1, ABOVE_NORMAL_PRIORITY_CLASS},
{2, HIGH_PRIORITY_CLASS},
{3, REALTIME_PRIORITY_CLASS}};
bool SetProcessPriorityClass(const uint32_t priority_class) {
if (!xeniaToWindowsPriorityClassMapping.count(priority_class)) {
return false;
}
return SetPriorityClass(GetCurrentProcess(),
xeniaToWindowsPriorityClassMapping[priority_class]);
}
} // namespace xe