Class naming fix
parent
18f9bfb575
commit
c2387b4b56
|
@ -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;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <memory>
|
||||
|
||||
/**
|
||||
* \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<typename Resource>
|
||||
class ResourceOwningThread
|
||||
class CResourceOwningThread
|
||||
{
|
||||
public:
|
||||
using ResourceUPtr = std::unique_ptr<Resource>;
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -2,20 +2,24 @@
|
|||
|
||||
#include <SDL_thread.h>
|
||||
|
||||
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*()
|
||||
{
|
||||
|
|
|
@ -2,20 +2,24 @@
|
|||
|
||||
#include <SDL_thread.h>
|
||||
|
||||
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*()
|
||||
{
|
||||
|
|
|
@ -496,7 +496,7 @@ void CEngine::WriteScreenShot(const std::string& fileName, int width, int height
|
|||
|
||||
data->fileName = fileName;
|
||||
|
||||
ResourceOwningThread<WriteScreenShotData> thread(CEngine::WriteScreenShotThread, std::move(data));
|
||||
CResourceOwningThread<WriteScreenShotData> thread(CEngine::WriteScreenShotThread, std::move(data));
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue