From 5b44617f9f6afbc438e3dedf3e5033c9079d7c1d Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 20 Sep 2016 07:45:04 -0700 Subject: [PATCH] Add missing files --- project/include/system/Mutex.h | 31 +++++++++++++ project/src/backend/sdl/SDLMutex.cpp | 65 ++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 project/include/system/Mutex.h create mode 100644 project/src/backend/sdl/SDLMutex.cpp diff --git a/project/include/system/Mutex.h b/project/include/system/Mutex.h new file mode 100644 index 000000000..94fb92e41 --- /dev/null +++ b/project/include/system/Mutex.h @@ -0,0 +1,31 @@ +#ifndef LIME_SYSTEM_MUTEX_H +#define LIME_SYSTEM_MUTEX_H + + +namespace lime { + + + class Mutex { + + + public: + + Mutex (); + ~Mutex (); + + bool Lock (); + bool TryLock (); + bool Unlock (); + + private: + + void* mutex; + + + }; + + +} + + +#endif \ No newline at end of file diff --git a/project/src/backend/sdl/SDLMutex.cpp b/project/src/backend/sdl/SDLMutex.cpp new file mode 100644 index 000000000..a67c6b64f --- /dev/null +++ b/project/src/backend/sdl/SDLMutex.cpp @@ -0,0 +1,65 @@ +#include +#include + + +namespace lime { + + + Mutex::Mutex () { + + mutex = SDL_CreateMutex (); + + } + + + Mutex::~Mutex () { + + if (mutex) { + + SDL_DestroyMutex ((SDL_mutex*)mutex); + + } + + } + + + bool Mutex::Lock () { + + if (mutex) { + + return SDL_LockMutex ((SDL_mutex*)mutex) == 0; + + } + + return false; + + } + + + bool Mutex::TryLock () { + + if (mutex) { + + return SDL_TryLockMutex ((SDL_mutex*)mutex) == 0; + + } + + return false; + + } + + + bool Mutex::Unlock () { + + if (mutex) { + + return SDL_UnlockMutex ((SDL_mutex*)mutex) == 0; + + } + + return false; + + } + + +} \ No newline at end of file