2017-12-16 00:31:23 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <SDL2/SDL_log.h>
|
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
|
|
|
|
void mutex_lock(SDL_mutex *mutex) {
|
|
|
|
if (SDL_LockMutex(mutex)) {
|
2018-02-12 23:06:53 +08:00
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not lock mutex");
|
2017-12-16 00:31:23 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mutex_unlock(SDL_mutex *mutex) {
|
|
|
|
if (SDL_UnlockMutex(mutex)) {
|
2018-02-12 23:06:53 +08:00
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not unlock mutex");
|
2017-12-16 00:31:23 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cond_wait(SDL_cond *cond, SDL_mutex *mutex) {
|
|
|
|
if (SDL_CondWait(cond, mutex)) {
|
2018-02-12 23:06:53 +08:00
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not wait on condition");
|
2017-12-16 00:31:23 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cond_signal(SDL_cond *cond) {
|
|
|
|
if (SDL_CondSignal(cond)) {
|
2018-02-12 23:06:53 +08:00
|
|
|
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Could not signal a condition");
|
2017-12-16 00:31:23 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|