diff options
| author | 2022-04-07 13:52:51 -0500 | |
|---|---|---|
| committer | 2022-04-07 13:52:51 -0500 | |
| commit | 9c85cb354a6c00f82278e6c39d4b474c49dd4c5a (patch) | |
| tree | 4dfac6429ce3019c7c7a8d4f477f6ac8ec873915 /src/core/hid/emulated_console.cpp | |
| parent | core: hid: Reduce the amount of dataraces (diff) | |
| download | yuzu-9c85cb354a6c00f82278e6c39d4b474c49dd4c5a.tar.gz yuzu-9c85cb354a6c00f82278e6c39d4b474c49dd4c5a.tar.xz yuzu-9c85cb354a6c00f82278e6c39d4b474c49dd4c5a.zip | |
core: hid: Replace lock_guard with scoped_lock
Diffstat (limited to 'src/core/hid/emulated_console.cpp')
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 639f61809..de565048b 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -197,27 +197,27 @@ void EmulatedConsole::SetTouch(const Common::Input::CallbackStatus& callback, st | |||
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | ConsoleMotionValues EmulatedConsole::GetMotionValues() const { | 199 | ConsoleMotionValues EmulatedConsole::GetMotionValues() const { |
| 200 | std::lock_guard lock{mutex}; | 200 | std::scoped_lock lock{mutex}; |
| 201 | return console.motion_values; | 201 | return console.motion_values; |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | TouchValues EmulatedConsole::GetTouchValues() const { | 204 | TouchValues EmulatedConsole::GetTouchValues() const { |
| 205 | std::lock_guard lock{mutex}; | 205 | std::scoped_lock lock{mutex}; |
| 206 | return console.touch_values; | 206 | return console.touch_values; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | ConsoleMotion EmulatedConsole::GetMotion() const { | 209 | ConsoleMotion EmulatedConsole::GetMotion() const { |
| 210 | std::lock_guard lock{mutex}; | 210 | std::scoped_lock lock{mutex}; |
| 211 | return console.motion_state; | 211 | return console.motion_state; |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | TouchFingerState EmulatedConsole::GetTouch() const { | 214 | TouchFingerState EmulatedConsole::GetTouch() const { |
| 215 | std::lock_guard lock{mutex}; | 215 | std::scoped_lock lock{mutex}; |
| 216 | return console.touch_state; | 216 | return console.touch_state; |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) { | 219 | void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) { |
| 220 | std::lock_guard lock{callback_mutex}; | 220 | std::scoped_lock lock{callback_mutex}; |
| 221 | for (const auto& poller_pair : callback_list) { | 221 | for (const auto& poller_pair : callback_list) { |
| 222 | const ConsoleUpdateCallback& poller = poller_pair.second; | 222 | const ConsoleUpdateCallback& poller = poller_pair.second; |
| 223 | if (poller.on_change) { | 223 | if (poller.on_change) { |
| @@ -227,13 +227,13 @@ void EmulatedConsole::TriggerOnChange(ConsoleTriggerType type) { | |||
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | int EmulatedConsole::SetCallback(ConsoleUpdateCallback update_callback) { | 229 | int EmulatedConsole::SetCallback(ConsoleUpdateCallback update_callback) { |
| 230 | std::lock_guard lock{callback_mutex}; | 230 | std::scoped_lock lock{callback_mutex}; |
| 231 | callback_list.insert_or_assign(last_callback_key, update_callback); | 231 | callback_list.insert_or_assign(last_callback_key, update_callback); |
| 232 | return last_callback_key++; | 232 | return last_callback_key++; |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | void EmulatedConsole::DeleteCallback(int key) { | 235 | void EmulatedConsole::DeleteCallback(int key) { |
| 236 | std::lock_guard lock{callback_mutex}; | 236 | std::scoped_lock lock{callback_mutex}; |
| 237 | const auto& iterator = callback_list.find(key); | 237 | const auto& iterator = callback_list.find(key); |
| 238 | if (iterator == callback_list.end()) { | 238 | if (iterator == callback_list.end()) { |
| 239 | LOG_ERROR(Input, "Tried to delete non-existent callback {}", key); | 239 | LOG_ERROR(Input, "Tried to delete non-existent callback {}", key); |