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:
sukibaby
2025-03-02 09:04:34 -08:00
committed by teejusb
parent 1da7f6167f
commit 1b258a4a00
+9 -2
View File
@@ -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()