Skip to content

Commit

Permalink
gsdx sw: improve exit condition of SW extra thread
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gregory38 committed Jul 14, 2016
1 parent abc9f7d commit d855bc5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/GSdx/GSThread_CXX11.h
Expand Up @@ -113,7 +113,10 @@ template<class T, int CAPACITY> class GSJobQueue : public IGSJobQueue<T>
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);
}

Expand Down Expand Up @@ -144,8 +147,10 @@ template<class T, int CAPACITY> class GSJobQueue : public IGSJobQueue<T>
}

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

Expand Down

0 comments on commit d855bc5

Please sign in to comment.