From 7c7340e338455adb9f933d447b86a1eae54575b4 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 7 Dec 2021 18:24:01 -0800 Subject: [PATCH] ThreadManager: Check for exchange failure. Even if expected stays null, since it's weak assume it can fail. --- Common/Thread/ThreadManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/Thread/ThreadManager.cpp b/Common/Thread/ThreadManager.cpp index 588e88d520..4dad152ed3 100644 --- a/Common/Thread/ThreadManager.cpp +++ b/Common/Thread/ThreadManager.cpp @@ -264,11 +264,11 @@ void ThreadManager::EnqueueTaskOnThread(int threadNum, Task *task) { // Try first atomically, as highest priority. Task *expected = nullptr; - thread->private_single.compare_exchange_weak(expected, task); + bool queued = thread->private_single.compare_exchange_weak(expected, task); // Whether we got that or will have to wait, increase the queue counter. thread->queue_size++; - if (expected == nullptr) { + if (queued) { std::unique_lock lock(thread->mutex); thread->cond.notify_one(); } else {