mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 08:09:26 +01:00
Re-enable the std::mutex try_lock on linux and use it for the Host_GetKeyState keystate_lock mutex. This reduces the number of application crashes on linux during emulation.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7334 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
1b583a0441
commit
0cc8eda124
@ -157,15 +157,17 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
// TryAcquireSRWLockExclusive requires Windows 7!!
|
||||
// bool try_lock()
|
||||
// {
|
||||
//#ifdef _WIN32
|
||||
// return (0 != TryAcquireSRWLockExclusive(&m_handle));
|
||||
//#else
|
||||
// return !pthread_mutex_trylock(&m_handle);
|
||||
//#endif
|
||||
// }
|
||||
bool try_lock()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return (0 != TryAcquireSRWLockExclusive(&m_handle));
|
||||
#else
|
||||
return !pthread_mutex_trylock(&m_handle);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
native_handle_type native_handle()
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ class CFrame : public CRenderFrame
|
||||
#ifdef __WXGTK__
|
||||
Common::Event panic_event;
|
||||
bool bPanicResult;
|
||||
std::recursive_mutex keystate_lock;
|
||||
std::mutex keystate_lock;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
|
@ -1023,7 +1023,7 @@ void CFrame::DoStop()
|
||||
{
|
||||
#if defined __WXGTK__
|
||||
wxMutexGuiLeave();
|
||||
std::lock_guard<std::recursive_mutex> lk(keystate_lock);
|
||||
std::lock_guard<std::mutex> lk(keystate_lock);
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
// Ask for confirmation in case the user accidentally clicked Stop / Escape
|
||||
|
@ -584,8 +584,8 @@ bool Host_GetKeyState(int keycode)
|
||||
#ifdef _WIN32
|
||||
return GetAsyncKeyState(keycode);
|
||||
#elif defined __WXGTK__
|
||||
std::unique_lock<std::recursive_mutex> lk(main_frame->keystate_lock, std::try_to_lock);
|
||||
if (!lk.owns_lock())
|
||||
std::unique_lock<std::mutex> lk(main_frame->keystate_lock, std::defer_lock);
|
||||
if (!lk.try_lock())
|
||||
return false;
|
||||
|
||||
bool key_pressed;
|
||||
|
Loading…
x
Reference in New Issue
Block a user