diff --git a/Source/dthread.cpp b/Source/dthread.cpp index 4c4d9f1da..0a91f85b8 100644 --- a/Source/dthread.cpp +++ b/Source/dthread.cpp @@ -9,7 +9,7 @@ #include "nthread.h" #include "utils/sdl_cond.h" -#include "utils/thread.h" +#include "utils/sdl_thread.h" namespace devilution { @@ -31,13 +31,12 @@ struct DThreadPkt { namespace { std::optional DthreadMutex; -SDL_threadID glpDThreadId; std::list InfoList; bool DthreadRunning; std::optional WorkToDo; /* rdata */ -SDL_Thread *sghThread = nullptr; +SdlThread Thread; void DthreadHandler() { @@ -87,7 +86,7 @@ void dthread_start() DthreadRunning = true; DthreadMutex.emplace(); WorkToDo.emplace(); - sghThread = CreateThread(DthreadHandler, &glpDThreadId); + Thread = { DthreadHandler }; } void DThreadCleanup() @@ -102,11 +101,7 @@ void DThreadCleanup() WorkToDo->signal(); } - if (sghThread != nullptr && glpDThreadId != SDL_GetThreadID(nullptr)) { - SDL_WaitThread(sghThread, nullptr); - sghThread = nullptr; - } - + Thread.join(); DthreadMutex = std::nullopt; WorkToDo = std::nullopt; }