diff --git a/src/common/event.h b/src/common/event.h index db33c200..200b8aa1 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -760,7 +760,7 @@ public: bool GetEvent(Event &event); protected: - SDLMutexWrapper m_mutex; + CSDLMutexWrapper m_mutex; Event m_fifo[MAX_EVENT_QUEUE]; int m_head; int m_tail; diff --git a/src/common/thread/resource_owning_thread.h b/src/common/thread/resource_owning_thread.h index 2f7de773..33012200 100644 --- a/src/common/thread/resource_owning_thread.h +++ b/src/common/thread/resource_owning_thread.h @@ -8,7 +8,7 @@ #include /** - * \class ResourceOwningThread + * \class CResourceOwningThread * \brief Wrapper around SDL thread allowing passing of resources in safe manner * * This class is a workaround for passing ownership of resources in a safe @@ -27,21 +27,21 @@ * way of doing this. */ template -class ResourceOwningThread +class CResourceOwningThread { public: using ResourceUPtr = std::unique_ptr; using ThreadFunctionPtr = void(*)(ResourceUPtr); - ResourceOwningThread(ThreadFunctionPtr threadFunction, ResourceUPtr resource) + CResourceOwningThread(ThreadFunctionPtr threadFunction, ResourceUPtr resource) : m_threadFunction(threadFunction), m_resource(std::move(resource)) {} void Start() { - SDLMutexWrapper mutex; - SDLCondWrapper cond; + CSDLMutexWrapper mutex; + CSDLCondWrapper cond; bool condition = false; ThreadData data; @@ -87,8 +87,8 @@ private: struct ThreadData { ResourceUPtr resource; - SDLMutexWrapper* mutex = nullptr; - SDLCondWrapper* cond = nullptr; + CSDLMutexWrapper* mutex = nullptr; + CSDLCondWrapper* cond = nullptr; bool* condition = nullptr; ThreadFunctionPtr threadFunction = nullptr; }; diff --git a/src/common/thread/sdl_cond_wrapper.h b/src/common/thread/sdl_cond_wrapper.h index 1d970083..5f448312 100644 --- a/src/common/thread/sdl_cond_wrapper.h +++ b/src/common/thread/sdl_cond_wrapper.h @@ -2,20 +2,24 @@ #include -class SDLCondWrapper +/** + * \class CSDLCondWrapper + * \brief Wrapper for safe creation/deletion of SDL_cond + */ +class CSDLCondWrapper { public: - SDLCondWrapper() + CSDLCondWrapper() : m_cond(SDL_CreateCond()) {} - ~SDLCondWrapper() + ~CSDLCondWrapper() { SDL_DestroyCond(m_cond); } - SDLCondWrapper(const SDLCondWrapper&) = delete; - SDLCondWrapper& operator=(const SDLCondWrapper&) = delete; + CSDLCondWrapper(const CSDLCondWrapper&) = delete; + CSDLCondWrapper& operator=(const CSDLCondWrapper&) = delete; SDL_cond* operator*() { diff --git a/src/common/thread/sdl_mutex_wrapper.h b/src/common/thread/sdl_mutex_wrapper.h index a43555f9..9227b50d 100644 --- a/src/common/thread/sdl_mutex_wrapper.h +++ b/src/common/thread/sdl_mutex_wrapper.h @@ -2,20 +2,24 @@ #include -class SDLMutexWrapper +/** + * \class CSDLMutexWrapper + * \brief Wrapper for safe creation/deletion of SDL_mutex + */ +class CSDLMutexWrapper { public: - SDLMutexWrapper() + CSDLMutexWrapper() : m_mutex(SDL_CreateMutex()) {} - ~SDLMutexWrapper() + ~CSDLMutexWrapper() { SDL_DestroyMutex(m_mutex); } - SDLMutexWrapper(const SDLMutexWrapper&) = delete; - SDLMutexWrapper& operator=(const SDLMutexWrapper&) = delete; + CSDLMutexWrapper(const CSDLMutexWrapper&) = delete; + CSDLMutexWrapper& operator=(const CSDLMutexWrapper&) = delete; SDL_mutex* operator*() { diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index b2a3f91d..238970cc 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -496,7 +496,7 @@ void CEngine::WriteScreenShot(const std::string& fileName, int width, int height data->fileName = fileName; - ResourceOwningThread thread(CEngine::WriteScreenShotThread, std::move(data)); + CResourceOwningThread thread(CEngine::WriteScreenShotThread, std::move(data)); thread.Start(); }