From d855bc5ca809fac972e0f3b71a35c6a72527ff76 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 14 Jul 2016 10:19:54 +0200 Subject: [PATCH] gsdx sw: improve exit condition of SW extra thread Use a relaxed atomic to read the exit variable in the hot path Wait that exit is deasserted in the destructor, so we are sure the thread will "soon" return --- plugins/GSdx/GSThread_CXX11.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/GSdx/GSThread_CXX11.h b/plugins/GSdx/GSThread_CXX11.h index 21711814ba..49e5904e05 100644 --- a/plugins/GSdx/GSThread_CXX11.h +++ b/plugins/GSdx/GSThread_CXX11.h @@ -113,7 +113,10 @@ protected: while (true) { while (m_count == 0) { - if (m_exit.load(memory_order_acquire)) return; + if (m_exit.load(memory_order_relaxed)) { + m_exit = false; + return; + } m_notempty.wait(l); } @@ -144,8 +147,10 @@ public: } virtual ~GSJobQueue() { - m_exit.store(true, memory_order_release); - m_notempty.notify_one(); + m_exit = true; + do { + m_notempty.notify_one(); + } while (m_exit); this->CloseThread(); }