void detachThread(ThreadIdentifier threadID) { ASSERT(threadID); HANDLE threadHandle = threadHandleForIdentifier(threadID); if (threadHandle) CloseHandle(threadHandle); clearThreadHandleForIdentifier(threadID); }
void changeThreadPriority(ThreadIdentifier threadID, int delta) { ASSERT(threadID); HANDLE threadHandle = threadHandleForIdentifier(threadID); if (!threadHandle) LOG_ERROR("ThreadIdentifier %u does not correspond to an active thread", threadID); SetThreadPriority(threadHandle, THREAD_PRIORITY_NORMAL + delta); }
int waitForThreadCompletion(ThreadIdentifier threadID, void** result) { ASSERT(threadID); HANDLE threadHandle = threadHandleForIdentifier(threadID); if (!threadHandle) LOG_ERROR("ThreadIdentifier %u did not correspond to an active thread when trying to quit", threadID); DWORD joinResult = WaitForSingleObject(threadHandle, INFINITE); if (joinResult == WAIT_FAILED) LOG_ERROR("ThreadIdentifier %u was found to be deadlocked trying to quit", threadID); CloseHandle(threadHandle); clearThreadHandleForIdentifier(threadID); return joinResult; }