| 2123 | |
| 2124 | typedef WINBASEAPI BOOL (WINAPI *pfnSwitchToThread) (); |
| 2125 | static inline BOOL switchToThread() |
| 2126 | { |
| 2127 | static pfnSwitchToThread fnSwitchToThread = NULL; |
| 2128 | static bool bInit = false; |
| 2129 | |
| 2130 | if (!bInit) |
| 2131 | { |
| 2132 | HMODULE hLib = GetModuleHandle("kernel32.dll"); |
| 2133 | if (hLib) |
| 2134 | fnSwitchToThread = (pfnSwitchToThread) GetProcAddress(hLib, "SwitchToThread"); |
| 2135 | |
| 2136 | bInit = true; |
| 2137 | } |
| 2138 | |
| 2139 | BOOL res = FALSE; |
| 2140 | |
| 2141 | if (fnSwitchToThread) |
| 2142 | { |
| 2143 | const HANDLE hThread = GetCurrentThread(); |
| 2144 | SetThreadPriority(hThread, THREAD_PRIORITY_ABOVE_NORMAL); |
| 2145 | |
| 2146 | res = (*fnSwitchToThread)(); |
| 2147 | |
| 2148 | SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL); |
| 2149 | } |
| 2150 | |
| 2151 | return res; |
| 2152 | } |
| 2153 | |
| 2154 | |
| 2155 | // MinGW has the wrong declaration for the operating system function. |
no outgoing calls
no test coverage detected