[MISC] Allow user to override process priority class
This commit is contained in:
committed by
Radosław Gliński
parent
82cb261140
commit
cf0ee05da6
@@ -27,6 +27,8 @@ void ShutdownAndroidSystem();
|
||||
void LaunchWebBrowser(const std::string_view url);
|
||||
void LaunchFileExplorer(const std::filesystem::path& path);
|
||||
|
||||
bool SetProcessPriorityClass(const uint32_t priority_class);
|
||||
|
||||
enum class SimpleMessageBoxType {
|
||||
Help,
|
||||
Warning,
|
||||
|
||||
@@ -294,4 +294,6 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type, std::string_view message) {
|
||||
// Java VM for the calling thread is needed.
|
||||
}
|
||||
|
||||
bool SetProcessPriorityClass(const uint32_t priority_class) { return true; }
|
||||
|
||||
} // namespace xe
|
||||
|
||||
@@ -67,4 +67,6 @@ void ShowSimpleMessageBox(SimpleMessageBoxType type, std::string_view message) {
|
||||
}
|
||||
}
|
||||
|
||||
bool SetProcessPriorityClass(const uint32_t priority_class) { return true; }
|
||||
|
||||
} // namespace xe
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user