diff options
| author | 2022-04-07 19:30:55 +0100 | |
|---|---|---|
| committer | 2022-04-07 19:30:55 +0100 | |
| commit | c589db6adde8e4706065b1ab00bd6814b39dc8bb (patch) | |
| tree | 19430d5342df4de9b8fc196012e53b09fb8f5f41 /src | |
| parent | Merge pull request #8161 from liamwhite/gl-s8d24 (diff) | |
| download | yuzu-c589db6adde8e4706065b1ab00bd6814b39dc8bb.tar.gz yuzu-c589db6adde8e4706065b1ab00bd6814b39dc8bb.tar.xz yuzu-c589db6adde8e4706065b1ab00bd6814b39dc8bb.zip | |
common: Replace lock_guard with scoped_lock
Diffstat (limited to '')
| -rw-r--r-- | src/common/host_memory.cpp | 4 | ||||
| -rw-r--r-- | src/common/thread.h | 2 | ||||
| -rw-r--r-- | src/common/threadsafe_queue.h | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index e829af1ac..802943eb7 100644 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp | |||
| @@ -149,7 +149,7 @@ public: | |||
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void Unmap(size_t virtual_offset, size_t length) { | 151 | void Unmap(size_t virtual_offset, size_t length) { |
| 152 | std::lock_guard lock{placeholder_mutex}; | 152 | std::scoped_lock lock{placeholder_mutex}; |
| 153 | 153 | ||
| 154 | // Unmap until there are no more placeholders | 154 | // Unmap until there are no more placeholders |
| 155 | while (UnmapOnePlaceholder(virtual_offset, length)) { | 155 | while (UnmapOnePlaceholder(virtual_offset, length)) { |
| @@ -169,7 +169,7 @@ public: | |||
| 169 | } | 169 | } |
| 170 | const size_t virtual_end = virtual_offset + length; | 170 | const size_t virtual_end = virtual_offset + length; |
| 171 | 171 | ||
| 172 | std::lock_guard lock{placeholder_mutex}; | 172 | std::scoped_lock lock{placeholder_mutex}; |
| 173 | auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end}); | 173 | auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end}); |
| 174 | while (it != end) { | 174 | while (it != end) { |
| 175 | const size_t offset = std::max(it->lower(), virtual_offset); | 175 | const size_t offset = std::max(it->lower(), virtual_offset); |
diff --git a/src/common/thread.h b/src/common/thread.h index a8c17c71a..626609372 100644 --- a/src/common/thread.h +++ b/src/common/thread.h | |||
| @@ -17,7 +17,7 @@ namespace Common { | |||
| 17 | class Event { | 17 | class Event { |
| 18 | public: | 18 | public: |
| 19 | void Set() { | 19 | void Set() { |
| 20 | std::lock_guard lk{mutex}; | 20 | std::scoped_lock lk{mutex}; |
| 21 | if (!is_set) { | 21 | if (!is_set) { |
| 22 | is_set = true; | 22 | is_set = true; |
| 23 | condvar.notify_one(); | 23 | condvar.notify_one(); |
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index 2c8c2b90e..7272ac6e8 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h | |||
| @@ -52,7 +52,7 @@ public: | |||
| 52 | // line before cv.wait | 52 | // line before cv.wait |
| 53 | // TODO(bunnei): This can be replaced with C++20 waitable atomics when properly supported. | 53 | // TODO(bunnei): This can be replaced with C++20 waitable atomics when properly supported. |
| 54 | // See discussion on https://github.com/yuzu-emu/yuzu/pull/3173 for details. | 54 | // See discussion on https://github.com/yuzu-emu/yuzu/pull/3173 for details. |
| 55 | std::lock_guard lock{cv_mutex}; | 55 | std::scoped_lock lock{cv_mutex}; |
| 56 | cv.notify_one(); | 56 | cv.notify_one(); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -159,7 +159,7 @@ public: | |||
| 159 | 159 | ||
| 160 | template <typename Arg> | 160 | template <typename Arg> |
| 161 | void Push(Arg&& t) { | 161 | void Push(Arg&& t) { |
| 162 | std::lock_guard lock{write_lock}; | 162 | std::scoped_lock lock{write_lock}; |
| 163 | spsc_queue.Push(t); | 163 | spsc_queue.Push(t); |
| 164 | } | 164 | } |
| 165 | 165 | ||