use ExitThread instead of TerminateThread
Preferred in Windows, especially when we can't guarantee that we are able to perform a proper clean-up before terminating. Halt may be called with the Kill flag which indicates everything must shut down. This is the preferred approach in the Windows API. Another preferred option is to use WaitForSingleObject with a timeout, but Halt with the Kill flag is being called when the game is about to crash, so that's not a realistic option and may cause the program to hang indefinitely.
This commit is contained in:
@@ -43,9 +43,16 @@ HANDLE Win32ThreadIdToHandle(uint64_t iID)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ThreadImpl_Win32::Halt(bool /*Kill*/)
|
||||
void ThreadImpl_Win32::Halt(bool Kill)
|
||||
{
|
||||
SuspendThread(ThreadHandle);
|
||||
if (Kill)
|
||||
{
|
||||
ExitThread(0); // 0 indicates the thread was terminated
|
||||
}
|
||||
else
|
||||
{
|
||||
SuspendThread(ThreadHandle);
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadImpl_Win32::Resume()
|
||||
|
||||
Reference in New Issue
Block a user