Core: Improved threading interrupted detection
Vicki Pfau vi@endrift.com
Wed, 28 Jun 2017 14:10:31 -0700
2 files changed,
7 insertions(+),
6 deletions(-)
M
src/core/thread.c
→
src/core/thread.c
@@ -468,7 +468,7 @@
bool mCoreThreadIsPaused(struct mCoreThread* threadContext) { bool isPaused; MutexLock(&threadContext->stateMutex); - if (threadContext->state == THREAD_INTERRUPTED || threadContext->state == THREAD_INTERRUPTING) { + if (threadContext->interruptDepth) { isPaused = threadContext->savedState == THREAD_PAUSED; } else { isPaused = threadContext->state == THREAD_PAUSED;@@ -498,7 +498,7 @@
void mCoreThreadPauseFromThread(struct mCoreThread* threadContext) { bool frameOn = true; MutexLock(&threadContext->stateMutex); - if (threadContext->state == THREAD_RUNNING || (threadContext->state == THREAD_INTERRUPTING && threadContext->savedState == THREAD_RUNNING)) { + if (threadContext->state == THREAD_RUNNING || (threadContext->interruptDepth && threadContext->savedState == THREAD_RUNNING)) { threadContext->state = THREAD_PAUSING; frameOn = false; }@@ -509,11 +509,11 @@ }
void mCoreThreadSetRewinding(struct mCoreThread* threadContext, bool rewinding) { MutexLock(&threadContext->stateMutex); - if (rewinding && (threadContext->state == THREAD_REWINDING || (threadContext->state == THREAD_INTERRUPTING && threadContext->savedState == THREAD_REWINDING))) { + if (rewinding && (threadContext->state == THREAD_REWINDING || (threadContext->interruptDepth && threadContext->savedState == THREAD_REWINDING))) { MutexUnlock(&threadContext->stateMutex); return; } - if (!rewinding && (threadContext->state == THREAD_RUNNING || (threadContext->state == THREAD_INTERRUPTING && threadContext->savedState == THREAD_RUNNING))) { + if (!rewinding && ((!threadContext->interruptDepth && threadContext->state != THREAD_REWINDING) || (threadContext->interruptDepth && threadContext->savedState != THREAD_REWINDING))) { MutexUnlock(&threadContext->stateMutex); return; }@@ -529,7 +529,7 @@ }
void mCoreThreadWaitFromThread(struct mCoreThread* threadContext) { MutexLock(&threadContext->stateMutex); - if ((threadContext->state == THREAD_INTERRUPTED || threadContext->state == THREAD_INTERRUPTING) && threadContext->savedState == THREAD_RUNNING) { + if (threadContext->interruptDepth && threadContext->savedState == THREAD_RUNNING) { threadContext->savedState = THREAD_WAITING; } else if (threadContext->state == THREAD_RUNNING) { threadContext->state = THREAD_WAITING;@@ -539,7 +539,7 @@ }
void mCoreThreadStopWaiting(struct mCoreThread* threadContext) { MutexLock(&threadContext->stateMutex); - if ((threadContext->state == THREAD_INTERRUPTED || threadContext->state == THREAD_INTERRUPTING) && threadContext->savedState == THREAD_WAITING) { + if (threadContext->interruptDepth && threadContext->savedState == THREAD_WAITING) { threadContext->savedState = THREAD_RUNNING; } else if (threadContext->state == THREAD_WAITING) { threadContext->state = THREAD_RUNNING;