BACKENDS: Refactor the API for creating Mutexes
This commit is contained in:
parent
dcd537337b
commit
5022489277
40 changed files with 341 additions and 336 deletions
|
@ -27,21 +27,23 @@
|
|||
#include "backends/mutex/sdl/sdl-mutex.h"
|
||||
#include "backends/platform/sdl/sdl-sys.h"
|
||||
|
||||
/**
|
||||
* SDL mutex manager
|
||||
*/
|
||||
class SdlMutexInternal final : public Common::MutexInternal {
|
||||
public:
|
||||
SdlMutexInternal() { _mutex = SDL_CreateMutex(); }
|
||||
virtual ~SdlMutexInternal() override { SDL_DestroyMutex(_mutex); }
|
||||
|
||||
OSystem::MutexRef SdlMutexManager::createMutex() {
|
||||
return (OSystem::MutexRef) SDL_CreateMutex();
|
||||
}
|
||||
virtual bool lock() override { return (SDL_mutexP(_mutex) == 0); }
|
||||
virtual bool unlock() override { return (SDL_mutexV(_mutex) == 0); }
|
||||
|
||||
void SdlMutexManager::lockMutex(OSystem::MutexRef mutex) {
|
||||
SDL_mutexP((SDL_mutex *)mutex);
|
||||
}
|
||||
private:
|
||||
SDL_mutex *_mutex;
|
||||
};
|
||||
|
||||
void SdlMutexManager::unlockMutex(OSystem::MutexRef mutex) {
|
||||
SDL_mutexV((SDL_mutex *)mutex);
|
||||
}
|
||||
|
||||
void SdlMutexManager::deleteMutex(OSystem::MutexRef mutex) {
|
||||
SDL_DestroyMutex((SDL_mutex *)mutex);
|
||||
Common::MutexInternal *createSdlMutexInternal() {
|
||||
return new SdlMutexInternal();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue