mirror of https://github.com/encounter/SDL.git
Fixed bug 4992 - UWP/WinRT does not set thread priority when using SDL_SetThreadPriority
Ethan Lee Attached is a diff that I used to get SetThreadPriority working locally. I still have no idea what the minimum SDK version is since Microsoft never documented it, but it's worth pointing out that they're much more aggressive about using the latest VS and UWP SDK anyway (for example, an updated Xbox is no longer compatible with VS2017, and updates are required to have a network connection of any kind).
This commit is contained in:
parent
1af31a26d1
commit
bd5da73afd
|
@ -96,19 +96,30 @@ extern "C"
|
|||
int
|
||||
SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
|
||||
{
|
||||
// Thread priorities do not look to be settable via C++11's thread
|
||||
// interface, at least as of this writing (Nov 2012). std::thread does
|
||||
// provide access to the OS' native handle, however, and some form of
|
||||
// priority-setting could, in theory, be done through this interface.
|
||||
//
|
||||
// WinRT: UPDATE (Aug 20, 2013): thread priorities cannot be changed
|
||||
// on WinRT, at least not for any thread that's already been created.
|
||||
// WinRT threads appear to be based off of the WinRT class,
|
||||
// ThreadPool, more info on which can be found at:
|
||||
// http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.threading.threadpool.aspx
|
||||
//
|
||||
// For compatibility sake, 0 will be returned here.
|
||||
return (0);
|
||||
#ifdef __WINRT__
|
||||
int value;
|
||||
|
||||
if (priority == SDL_THREAD_PRIORITY_LOW) {
|
||||
value = THREAD_PRIORITY_LOWEST;
|
||||
}
|
||||
else if (priority == SDL_THREAD_PRIORITY_HIGH) {
|
||||
value = THREAD_PRIORITY_HIGHEST;
|
||||
}
|
||||
else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
|
||||
// FIXME: WinRT does not support TIME_CRITICAL! -flibit
|
||||
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "TIME_CRITICAL unsupported, falling back to HIGHEST");
|
||||
value = THREAD_PRIORITY_HIGHEST;
|
||||
}
|
||||
else {
|
||||
value = THREAD_PRIORITY_NORMAL;
|
||||
}
|
||||
if (!SetThreadPriority(GetCurrentThread(), value)) {
|
||||
return WIN_SetError("SetThreadPriority()");
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
return SDL_Unsupported();
|
||||
#endif
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
|
Loading…
Reference in New Issue