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
This commit is contained in:
Gregory Hainaut 2016-07-14 10:19:54 +02:00
parent abc9f7d096
commit d855bc5ca8
1 changed files with 8 additions and 3 deletions

View File

@ -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();
}