Fix Common::Barrier and fix the deadlock by making Common::Event check to see if an event has already been set or not.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7305 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
024a87af7a
commit
7bc2ae01f2
|
@ -51,18 +51,29 @@ void SetCurrentThreadAffinity(u32 mask);
|
||||||
class Event
|
class Event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Event()
|
||||||
|
: is_set(false)
|
||||||
|
{};
|
||||||
|
|
||||||
void Set()
|
void Set()
|
||||||
{
|
{
|
||||||
m_condvar.notify_one();
|
if (!is_set)
|
||||||
|
{
|
||||||
|
is_set = true;
|
||||||
|
m_condvar.notify_one();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wait()
|
void Wait()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_mutex);
|
std::unique_lock<std::mutex> lk(m_mutex);
|
||||||
m_condvar.wait(lk);
|
if (!is_set)
|
||||||
|
m_condvar.wait(lk);
|
||||||
|
is_set = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool is_set;
|
||||||
std::condition_variable m_condvar;
|
std::condition_variable m_condvar;
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
};
|
};
|
||||||
|
@ -71,10 +82,6 @@ private:
|
||||||
class Barrier
|
class Barrier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Barrier()
|
|
||||||
: m_count(2), m_waiting(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Barrier(size_t count)
|
Barrier(size_t count)
|
||||||
: m_count(count), m_waiting(0)
|
: m_count(count), m_waiting(0)
|
||||||
{}
|
{}
|
||||||
|
@ -84,7 +91,7 @@ public:
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_mutex);
|
std::unique_lock<std::mutex> lk(m_mutex);
|
||||||
|
|
||||||
if (m_count >= ++m_waiting)
|
if (m_count == ++m_waiting)
|
||||||
{
|
{
|
||||||
m_waiting = 0;
|
m_waiting = 0;
|
||||||
m_condvar.notify_all();
|
m_condvar.notify_all();
|
||||||
|
|
|
@ -665,7 +665,7 @@ void CFrame::OnHostMessage(wxCommandEvent& event)
|
||||||
break;
|
break;
|
||||||
case IDM_KEYSTATE:
|
case IDM_KEYSTATE:
|
||||||
bKeyStateResult = wxGetKeyState(wxKeyCode(event.GetInt()));
|
bKeyStateResult = wxGetKeyState(wxKeyCode(event.GetInt()));
|
||||||
keystate_event.Wait();
|
keystate_event.Set();
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ class CFrame : public CRenderFrame
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
Common::Event panic_event;
|
Common::Event panic_event;
|
||||||
bool bPanicResult;
|
bool bPanicResult;
|
||||||
Common::Barrier keystate_event;
|
Common::Event keystate_event;
|
||||||
bool bKeyStateResult;
|
bool bKeyStateResult;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ void CFrame::DoStop()
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
// Make sure the app doesn't hang waiting on a keystate check
|
// Make sure the app doesn't hang waiting on a keystate check
|
||||||
keystate_event.Wait();
|
keystate_event.Set();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BootManager::Stop();
|
BootManager::Stop();
|
||||||
|
|
Loading…
Reference in New Issue