summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2011-03-05 06:11:26 +0000
committerJordan Woyak <jordan.woyak@gmail.com>2011-03-05 06:11:26 +0000
commit423018f811ce8c1682735d33a3790031b8c08576 (patch)
tree6159a7109df3c83303f5e0a25457d5f60a015126 /Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp
parenta037ff23586c3dd16d394ae87783db0628335587 (diff)
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
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/ControllerInterface.cpp22
1 files changed, 12 insertions, 10 deletions
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<std::mutex> 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<std::mutex> 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;