Add missing files

This commit is contained in:
Joshua Granick
2016-09-20 07:45:04 -07:00
parent 9434bbf25c
commit 5b44617f9f
2 changed files with 96 additions and 0 deletions

View File

@@ -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

View File

@@ -0,0 +1,65 @@
#include <system/Mutex.h>
#include <SDL.h>
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;
}
}