From 3926db624d5ab2f959e67eb2369f1fe5f0f9543a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Fri, 15 Jul 2016 11:34:18 +0200 Subject: [PATCH] ControllerInterface: Don't block on UpdateInput() Changes UpdateInput() to skip if we can't lock the mutex, instead of potentially blocking the CPU thread and causing a short but noticeable frame drop. --- .../ControllerInterface/ControllerInterface.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp index cf726698f1..9c7a08428e 100644 --- a/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp +++ b/Source/Core/InputCommon/ControllerInterface/ControllerInterface.cpp @@ -175,9 +175,13 @@ void ControllerInterface::RemoveDevice(std::function lk(m_devices_mutex); - for (const auto& d : m_devices) - d->UpdateInput(); + // Don't block the UI or CPU thread (to avoid a short but noticeable frame drop) + if (m_devices_mutex.try_lock()) + { + std::lock_guard lk(m_devices_mutex, std::adopt_lock); + for (const auto& d : m_devices) + d->UpdateInput(); + } } //