From 44ed2ee3aa28e056324326a028efb477f17284a2 Mon Sep 17 00:00:00 2001 From: RadWolfie Date: Wed, 2 Feb 2022 17:49:54 -0600 Subject: [PATCH] update Timer_Shutdown to reduce wait time for shutdown if threads are all xbox --- src/common/Timer.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/common/Timer.cpp b/src/common/Timer.cpp index 6bcb73057..af569c1fd 100644 --- a/src/common/Timer.cpp +++ b/src/common/Timer.cpp @@ -126,17 +126,25 @@ void Timer_Destroy(TimerObject* Timer) void Timer_Shutdown() { - unsigned int index, i; + unsigned i, iXboxThreads = 0; TimerMtx.lock(); - index = TimerList.size(); - for (i = 0; i < index; i++) { + for (i = 0; i < TimerList.size(); i++) { TimerObject* Timer = TimerList[i]; - Timer_Exit(Timer); + // We only need to terminate host threads. + if (!Timer->IsXboxTimer) { + Timer_Exit(Timer); + } + // If the thread is xbox, we need to increment for while statement check + else { + iXboxThreads++; + } } + // Only perform wait for host threads, otherwise xbox threads are + // already handled within xbox kernel for shutdown process. See CxbxrKrnlSuspendThreads function. int counter = 0; - while (TimerList.size()) { + while (iXboxThreads != TimerList.size()) { if (counter >= 8) { break; }