2017-12-12 22:12:07 +08:00
|
|
|
#ifndef LOCKUTIL_H
|
|
|
|
#define LOCKUTIL_H
|
|
|
|
|
2017-12-15 23:37:17 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <SDL2/SDL_log.h>
|
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
|
|
|
|
static inline void mutex_lock(SDL_mutex *mutex) {
|
2017-12-12 22:12:07 +08:00
|
|
|
if (SDL_LockMutex(mutex)) {
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not lock mutex");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-15 23:37:17 +08:00
|
|
|
static inline void mutex_unlock(SDL_mutex *mutex) {
|
2017-12-12 22:12:07 +08:00
|
|
|
if (SDL_UnlockMutex(mutex)) {
|
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_SYSTEM, "Could not unlock mutex");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|