Class naming fix

master
Piotr Dziwinski 2015-08-04 20:57:53 +02:00
parent 18f9bfb575
commit c2387b4b56
5 changed files with 27 additions and 19 deletions

View File

@ -760,7 +760,7 @@ public:
bool GetEvent(Event &event); bool GetEvent(Event &event);
protected: protected:
SDLMutexWrapper m_mutex; CSDLMutexWrapper m_mutex;
Event m_fifo[MAX_EVENT_QUEUE]; Event m_fifo[MAX_EVENT_QUEUE];
int m_head; int m_head;
int m_tail; int m_tail;

View File

@ -8,7 +8,7 @@
#include <memory> #include <memory>
/** /**
* \class ResourceOwningThread * \class CResourceOwningThread
* \brief Wrapper around SDL thread allowing passing of resources in safe manner * \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 * This class is a workaround for passing ownership of resources in a safe
@ -27,21 +27,21 @@
* way of doing this. * way of doing this.
*/ */
template<typename Resource> template<typename Resource>
class ResourceOwningThread class CResourceOwningThread
{ {
public: public:
using ResourceUPtr = std::unique_ptr<Resource>; using ResourceUPtr = std::unique_ptr<Resource>;
using ThreadFunctionPtr = void(*)(ResourceUPtr); using ThreadFunctionPtr = void(*)(ResourceUPtr);
ResourceOwningThread(ThreadFunctionPtr threadFunction, ResourceUPtr resource) CResourceOwningThread(ThreadFunctionPtr threadFunction, ResourceUPtr resource)
: m_threadFunction(threadFunction), : m_threadFunction(threadFunction),
m_resource(std::move(resource)) m_resource(std::move(resource))
{} {}
void Start() void Start()
{ {
SDLMutexWrapper mutex; CSDLMutexWrapper mutex;
SDLCondWrapper cond; CSDLCondWrapper cond;
bool condition = false; bool condition = false;
ThreadData data; ThreadData data;
@ -87,8 +87,8 @@ private:
struct ThreadData struct ThreadData
{ {
ResourceUPtr resource; ResourceUPtr resource;
SDLMutexWrapper* mutex = nullptr; CSDLMutexWrapper* mutex = nullptr;
SDLCondWrapper* cond = nullptr; CSDLCondWrapper* cond = nullptr;
bool* condition = nullptr; bool* condition = nullptr;
ThreadFunctionPtr threadFunction = nullptr; ThreadFunctionPtr threadFunction = nullptr;
}; };

View File

@ -2,20 +2,24 @@
#include <SDL_thread.h> #include <SDL_thread.h>
class SDLCondWrapper /**
* \class CSDLCondWrapper
* \brief Wrapper for safe creation/deletion of SDL_cond
*/
class CSDLCondWrapper
{ {
public: public:
SDLCondWrapper() CSDLCondWrapper()
: m_cond(SDL_CreateCond()) : m_cond(SDL_CreateCond())
{} {}
~SDLCondWrapper() ~CSDLCondWrapper()
{ {
SDL_DestroyCond(m_cond); SDL_DestroyCond(m_cond);
} }
SDLCondWrapper(const SDLCondWrapper&) = delete; CSDLCondWrapper(const CSDLCondWrapper&) = delete;
SDLCondWrapper& operator=(const SDLCondWrapper&) = delete; CSDLCondWrapper& operator=(const CSDLCondWrapper&) = delete;
SDL_cond* operator*() SDL_cond* operator*()
{ {

View File

@ -2,20 +2,24 @@
#include <SDL_thread.h> #include <SDL_thread.h>
class SDLMutexWrapper /**
* \class CSDLMutexWrapper
* \brief Wrapper for safe creation/deletion of SDL_mutex
*/
class CSDLMutexWrapper
{ {
public: public:
SDLMutexWrapper() CSDLMutexWrapper()
: m_mutex(SDL_CreateMutex()) : m_mutex(SDL_CreateMutex())
{} {}
~SDLMutexWrapper() ~CSDLMutexWrapper()
{ {
SDL_DestroyMutex(m_mutex); SDL_DestroyMutex(m_mutex);
} }
SDLMutexWrapper(const SDLMutexWrapper&) = delete; CSDLMutexWrapper(const CSDLMutexWrapper&) = delete;
SDLMutexWrapper& operator=(const SDLMutexWrapper&) = delete; CSDLMutexWrapper& operator=(const CSDLMutexWrapper&) = delete;
SDL_mutex* operator*() SDL_mutex* operator*()
{ {

View File

@ -496,7 +496,7 @@ void CEngine::WriteScreenShot(const std::string& fileName, int width, int height
data->fileName = fileName; data->fileName = fileName;
ResourceOwningThread<WriteScreenShotData> thread(CEngine::WriteScreenShotThread, std::move(data)); CResourceOwningThread<WriteScreenShotData> thread(CEngine::WriteScreenShotThread, std::move(data));
thread.Start(); thread.Start();
} }