MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / switchToThread

Function switchToThread

src/common/isc_sync.cpp:2125–2152  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2123
2124typedef WINBASEAPI BOOL (WINAPI *pfnSwitchToThread) ();
2125static 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.

Callers 2

lockSharedSectionFunction · 0.85
initializeFastMutexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected