From 423018f811ce8c1682735d33a3790031b8c08576 Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Sat, 5 Mar 2011 06:11:26 +0000 Subject: Replaced Common::CriticalSection with a std::mutex implementation. 64bit Windows builds now use SRWLocks and ConditionVariables(requires Vista/7, x64 builds will no longer work on Windows XP x64). Tell me if you hate that. Removed Common::EventEx. Common::Event now uses a std::condition_variable impl.(using ConditionVariables on Windows x64, Events on x86, or posix condition variables elsewhere). I experience slight speed improvements with these changes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7294 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../ControllerInterface/ControllerInterface.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp') diff --git a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp index d1efdf1d93..16c633db78 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp @@ -118,10 +118,12 @@ void ControllerInterface::SetHwnd( void* const hwnd ) // bool ControllerInterface::UpdateInput(const bool force) { + std::unique_lock lk(update_lock, std::defer_lock); + if (force) - update_lock.Enter(); - else if (false == update_lock.TryEnter()) - return false; + lk.lock(); + else if (!lk.try_lock()) + return false; size_t ok_count = 0; @@ -137,7 +139,6 @@ bool ControllerInterface::UpdateInput(const bool force) //(*d)->ClearInputState(); } - update_lock.Leave(); return (m_devices.size() == ok_count); } @@ -148,10 +149,12 @@ bool ControllerInterface::UpdateInput(const bool force) // bool ControllerInterface::UpdateOutput(const bool force) { + std::unique_lock lk(update_lock, std::defer_lock); + if (force) - update_lock.Enter(); - else if (false == update_lock.TryEnter()) - return false; + lk.lock(); + else if (!lk.try_lock()) + return false; size_t ok_count = 0; @@ -161,7 +164,6 @@ bool ControllerInterface::UpdateOutput(const bool force) for (;d != e; ++d) (*d)->UpdateOutput(); - update_lock.Leave(); return (m_devices.size() == ok_count); } @@ -470,8 +472,8 @@ void ControllerInterface::UpdateReference(ControllerInterface::ControlReference* else if ('`' == c) { // different device - if (false == /*XXX*/(bool)std::getline(ss, dev_str, '`')) - break; + if (std::getline(ss, dev_str, '`').eof()) + break; // no terminating '`' character } else ctrl_str += c; -- cgit v1.2.3