Add missing files
This commit is contained in:
31
project/include/system/Mutex.h
Normal file
31
project/include/system/Mutex.h
Normal 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
|
||||||
65
project/src/backend/sdl/SDLMutex.cpp
Normal file
65
project/src/backend/sdl/SDLMutex.cpp
Normal 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user