Add missing files
This commit is contained in:
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