From 2e2ca19220c6ce39079c95e5eb923af02fcf4a69 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 28 Jan 2014 23:15:30 -0800 Subject: [PATCH] Add GBAThreadEnd function for manually shutting down the GBA thread --- src/gba/gba-thread.c | 9 +++++++++ src/gba/gba-thread.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index 9facc42bd..e37bde16f 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -193,6 +193,15 @@ int GBAThreadStart(struct GBAThread* threadContext) { return 0; } +void GBAThreadEnd(struct GBAThread* threadContext) { + MutexLock(&threadContext->stateMutex); + if (threadContext->debugger && threadContext->debugger->state == DEBUGGER_RUNNING) { + threadContext->debugger->state = DEBUGGER_EXITING; + } + threadContext->state = THREAD_EXITING; + MutexUnlock(&threadContext->stateMutex); +} + void GBAThreadJoin(struct GBAThread* threadContext) { MutexLock(&threadContext->sync.videoFrameMutex); threadContext->sync.videoFrameWait = 0; diff --git a/src/gba/gba-thread.h b/src/gba/gba-thread.h index 801fe5ee1..1e3844583 100644 --- a/src/gba/gba-thread.h +++ b/src/gba/gba-thread.h @@ -64,6 +64,7 @@ struct GBAThread { }; int GBAThreadStart(struct GBAThread* threadContext); +void GBAThreadEnd(struct GBAThread* threadContext); void GBAThreadJoin(struct GBAThread* threadContext); void GBAThreadPause(struct GBAThread* threadContext);