2017-12-16 00:31:23 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
|
2018-02-13 17:10:18 +08:00
|
|
|
#include "log.h"
|
|
|
|
|
2017-12-16 00:31:23 +08:00
|
|
|
void mutex_lock(SDL_mutex *mutex) {
|
|
|
|
if (SDL_LockMutex(mutex)) {
|
2018-02-13 17:10:18 +08:00
|
|
|
LOGC("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-13 17:10:18 +08:00
|
|
|
LOGC("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-13 17:10:18 +08:00
|
|
|
LOGC("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-13 17:10:18 +08:00
|
|
|
LOGC("Could not signal a condition");
|
2017-12-16 00:31:23 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|