Assert non-recursive usage of mutexes
This commit is contained in:
parent
54f5c42d7b
commit
c53bd4d8b6
1 changed files with 3 additions and 0 deletions
|
@ -43,6 +43,8 @@ sc_mutex_destroy(sc_mutex *mutex) {
|
||||||
|
|
||||||
void
|
void
|
||||||
sc_mutex_lock(sc_mutex *mutex) {
|
sc_mutex_lock(sc_mutex *mutex) {
|
||||||
|
// SDL mutexes are recursive, but we don't want to use recursive mutexes
|
||||||
|
assert(!sc_mutex_held(mutex));
|
||||||
int r = SDL_LockMutex(mutex->mutex);
|
int r = SDL_LockMutex(mutex->mutex);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (r) {
|
if (r) {
|
||||||
|
@ -59,6 +61,7 @@ sc_mutex_lock(sc_mutex *mutex) {
|
||||||
void
|
void
|
||||||
sc_mutex_unlock(sc_mutex *mutex) {
|
sc_mutex_unlock(sc_mutex *mutex) {
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
assert(sc_mutex_held(mutex));
|
||||||
mutex->locker = 0;
|
mutex->locker = 0;
|
||||||
#endif
|
#endif
|
||||||
int r = SDL_UnlockMutex(mutex->mutex);
|
int r = SDL_UnlockMutex(mutex->mutex);
|
||||||
|
|
Loading…
Reference in a new issue