diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h index ea4f8057db..cac189c6b0 100644 --- a/Source/Core/Common/Src/Thread.h +++ b/Source/Core/Common/Src/Thread.h @@ -51,18 +51,29 @@ void SetCurrentThreadAffinity(u32 mask); class Event { public: + Event() + : is_set(false) + {}; + void Set() { - m_condvar.notify_one(); + if (!is_set) + { + is_set = true; + m_condvar.notify_one(); + } } void Wait() { std::unique_lock lk(m_mutex); - m_condvar.wait(lk); + if (!is_set) + m_condvar.wait(lk); + is_set = false; } private: + bool is_set; std::condition_variable m_condvar; std::mutex m_mutex; }; @@ -71,10 +82,6 @@ private: class Barrier { public: - Barrier() - : m_count(2), m_waiting(0) - {} - Barrier(size_t count) : m_count(count), m_waiting(0) {} @@ -84,7 +91,7 @@ public: { std::unique_lock lk(m_mutex); - if (m_count >= ++m_waiting) + if (m_count == ++m_waiting) { m_waiting = 0; m_condvar.notify_all(); diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 3ec80afffd..ebfcc5e196 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -665,7 +665,7 @@ void CFrame::OnHostMessage(wxCommandEvent& event) break; case IDM_KEYSTATE: bKeyStateResult = wxGetKeyState(wxKeyCode(event.GetInt())); - keystate_event.Wait(); + keystate_event.Set(); break; #endif diff --git a/Source/Core/DolphinWX/Src/Frame.h b/Source/Core/DolphinWX/Src/Frame.h index ce04148e88..4a04aadd87 100644 --- a/Source/Core/DolphinWX/Src/Frame.h +++ b/Source/Core/DolphinWX/Src/Frame.h @@ -145,7 +145,7 @@ class CFrame : public CRenderFrame #ifdef __WXGTK__ Common::Event panic_event; bool bPanicResult; - Common::Barrier keystate_event; + Common::Event keystate_event; bool bKeyStateResult; #endif diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index 067210e2a2..408325ed23 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -1045,7 +1045,7 @@ void CFrame::DoStop() #ifdef __WXGTK__ // Make sure the app doesn't hang waiting on a keystate check - keystate_event.Wait(); + keystate_event.Set(); #endif BootManager::Stop();