From 1cf4e838246fbd6daec5e2caf9f9a21f8ea4980b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 15 Mar 2023 22:26:23 +0100 Subject: [PATCH 1/2] Show thread name in assert messagebox caption on Windows. Minor cleanup --- Common/Log.cpp | 3 ++- Common/Thread/Channel.h | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Common/Log.cpp b/Common/Log.cpp index d3f7ed9b02..28c2f821d0 100644 --- a/Common/Log.cpp +++ b/Common/Log.cpp @@ -24,6 +24,7 @@ #include "Common/Log.h" #include "StringUtils.h" #include "Common/Data/Encoding/Utf8.h" +#include "Common/Thread/ThreadUtil.h" #if PPSSPP_PLATFORM(ANDROID) #include @@ -71,7 +72,7 @@ bool HandleAssert(const char *function, const char *file, int line, const char * if (!getenv("CI")) { int msgBoxStyle = MB_ICONINFORMATION | MB_YESNO; std::wstring wtext = ConvertUTF8ToWString(formatted) + L"\n\nTry to continue?"; - std::wstring wcaption = ConvertUTF8ToWString(caption); + std::wstring wcaption = ConvertUTF8ToWString(std::string(caption) + " " + GetCurrentThreadName()); OutputDebugString(wtext.c_str()); if (IDYES != MessageBox(0, wtext.c_str(), wcaption.c_str(), msgBoxStyle)) { return false; diff --git a/Common/Thread/Channel.h b/Common/Thread/Channel.h index 82772bb6f4..836290240a 100644 --- a/Common/Thread/Channel.h +++ b/Common/Thread/Channel.h @@ -24,9 +24,7 @@ struct Mailbox { T Wait() { std::unique_lock lock(mutex_); - while (!dataReceived_) { - condvar_.wait(lock); - } + condvar_.wait(lock, [&] {return dataReceived_;}); return data_; } From f0f96750b1793c4b9a7ef05f5e785aac711fb617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 15 Mar 2023 22:31:24 +0100 Subject: [PATCH 2/2] After picking a task from the global queue, gotta break from the loop. --- Common/Thread/ThreadManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/Thread/ThreadManager.cpp b/Common/Thread/ThreadManager.cpp index a43d8ea55e..d6eb76e5ec 100644 --- a/Common/Thread/ThreadManager.cpp +++ b/Common/Thread/ThreadManager.cpp @@ -164,12 +164,14 @@ static void WorkerThreadFunc(GlobalThreadContext *global, TaskThreadContext *thr // We are processing one now, so mark that. thread->queue_size++; + break; } else if (thread->queue_size != 0) { // Check the thread, as we prefer a HIGH thread task to a global NORMAL task. std::unique_lock lock(thread->mutex); if (!thread->private_queue[p].empty()) { task = thread->private_queue[p].front(); thread->private_queue[p].pop_front(); + break; } } } @@ -198,9 +200,9 @@ static void WorkerThreadFunc(GlobalThreadContext *global, TaskThreadContext *thr if (task) { task->Run(); task->Release(); - // Reduce the queue size once complete. thread->queue_size--; + // _dbg_assert_(thread->queue_size == thread->private_queue[0].size() + thread->private_queue[1].size() + thread->private_queue[2].size()); } }