From a583fafa37c922646789371847772e348e026c9b Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Mon, 2 Jan 2017 12:11:14 +0000 Subject: [PATCH] gsdx: Use lock instead of loop to terminate threads --- plugins/GSdx/GSThread_CXX11.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/GSdx/GSThread_CXX11.h b/plugins/GSdx/GSThread_CXX11.h index 6aa54da977..bb48ddf41b 100644 --- a/plugins/GSdx/GSThread_CXX11.h +++ b/plugins/GSdx/GSThread_CXX11.h @@ -44,10 +44,9 @@ private: while (true) { while (m_count == 0) { - if (m_exit.load(memory_order_relaxed)) { - m_exit = false; + if (m_exit.load(memory_order_relaxed)) return; - } + m_notempty.wait(l); } @@ -87,10 +86,11 @@ public: ~GSJobQueue() { - m_exit = true; - do { - m_notempty.notify_one(); - } while (m_exit); + { + std::lock_guard l(m_lock); + m_exit = true; + } + m_notempty.notify_one(); m_thread.join(); }