Add thread-safe function for telling if the GBA thread has started

This commit is contained in:
Jeffrey Pfau 2014-02-03 03:41:32 -08:00
parent 0f6523941c
commit 285b94b66a
2 changed files with 9 additions and 0 deletions

View File

@ -185,6 +185,14 @@ int GBAThreadStart(struct GBAThread* threadContext) {
return 0; return 0;
} }
int GBAThreadHasStarted(struct GBAThread* threadContext) {
int hasStarted;
MutexLock(&threadContext->stateMutex);
hasStarted = threadContext->state > THREAD_INITIALIZED;
MutexUnlock(&threadContext->stateMutex);
return hasStarted;
}
void GBAThreadEnd(struct GBAThread* threadContext) { void GBAThreadEnd(struct GBAThread* threadContext) {
MutexLock(&threadContext->stateMutex); MutexLock(&threadContext->stateMutex);
if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) {

View File

@ -66,6 +66,7 @@ struct GBAThread {
}; };
int GBAThreadStart(struct GBAThread* threadContext); int GBAThreadStart(struct GBAThread* threadContext);
int GBAThreadHasStarted(struct GBAThread* threadContext);
void GBAThreadEnd(struct GBAThread* threadContext); void GBAThreadEnd(struct GBAThread* threadContext);
void GBAThreadJoin(struct GBAThread* threadContext); void GBAThreadJoin(struct GBAThread* threadContext);