From eb232690114374d0307c5b5b00c3d520353b7f1c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 3 Feb 2014 03:41:32 -0800 Subject: [PATCH] Add thread-safe function for telling if the GBA thread has started --- src/gba/gba-thread.c | 8 ++++++++ src/gba/gba-thread.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 318415ec1..22bb502cc 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -185,6 +185,14 @@ int GBAThreadStart(struct GBAThread* threadContext) { 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) { MutexLock(&threadContext->stateMutex); if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { diff --git a/src/gba/gba-thread.h b/src/gba/gba-thread.h index 33098b681..582d4990f 100644 --- a/src/gba/gba-thread.h +++ b/src/gba/gba-thread.h @@ -66,6 +66,7 @@ struct GBAThread { }; int GBAThreadStart(struct GBAThread* threadContext); +int GBAThreadHasStarted(struct GBAThread* threadContext); void GBAThreadEnd(struct GBAThread* threadContext); void GBAThreadJoin(struct GBAThread* threadContext);