From fc8fc46e1716592fe1f459e617c99366e264251c Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Tue, 20 Jul 2021 11:03:11 +0300 Subject: [PATCH] Use SdlThread in dthread.cpp --- Source/dthread.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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; }