add debug checks to verify proper calling threads for functions

for some functions, it matters...
This commit is contained in:
ac-stef
2017-05-24 11:25:15 +02:00
parent 969e7308be
commit b0dc65e50b
2 changed files with 9 additions and 0 deletions
+8
View File
@@ -953,6 +953,10 @@ void sl_detachthread(void *ti) // SDL can't actually detach threads, so this is
sem_oldthreads.post();
}
}
static uint32_t mainthreadid = SDL_ThreadID();
bool ismainthread() { return mainthreadid == SDL_ThreadID(); }
#else
struct sl_threadinfo { int (*fn)(void *); void *data; pthread_t handle; int res; volatile char done; };
@@ -997,6 +1001,10 @@ void sl_detachthread(void *ti)
sem_oldthreads.post();
}
}
static pthread_t mainthreadid = pthread_self();
bool ismainthread() { return pthread_equal(mainthreadid, pthread_self()) != 0; }
#endif
bool sl_pollthread(void *ti)
+1
View File
@@ -1023,6 +1023,7 @@ extern int sl_waitthread(void *ti);
extern bool sl_pollthread(void *ti);
extern void sl_detachthread(void *ti);
extern void sl_sleep(int duration);
extern bool ismainthread();
#endif