yuzu-emu
/
yuzu
Archived
1
0
Fork 0

common: Replace lock_guard with scoped_lock

This commit is contained in:
Merry 2022-04-07 19:30:55 +01:00
parent 4265372099
commit c589db6add
3 changed files with 5 additions and 5 deletions

View File

@ -149,7 +149,7 @@ public:
} }
void Unmap(size_t virtual_offset, size_t length) { void Unmap(size_t virtual_offset, size_t length) {
std::lock_guard lock{placeholder_mutex}; std::scoped_lock lock{placeholder_mutex};
// Unmap until there are no more placeholders // Unmap until there are no more placeholders
while (UnmapOnePlaceholder(virtual_offset, length)) { while (UnmapOnePlaceholder(virtual_offset, length)) {
@ -169,7 +169,7 @@ public:
} }
const size_t virtual_end = virtual_offset + length; const size_t virtual_end = virtual_offset + length;
std::lock_guard lock{placeholder_mutex}; std::scoped_lock lock{placeholder_mutex};
auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end}); auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end});
while (it != end) { while (it != end) {
const size_t offset = std::max(it->lower(), virtual_offset); const size_t offset = std::max(it->lower(), virtual_offset);

View File

@ -17,7 +17,7 @@ namespace Common {
class Event { class Event {
public: public:
void Set() { void Set() {
std::lock_guard lk{mutex}; std::scoped_lock lk{mutex};
if (!is_set) { if (!is_set) {
is_set = true; is_set = true;
condvar.notify_one(); condvar.notify_one();

View File

@ -52,7 +52,7 @@ public:
// line before cv.wait // line before cv.wait
// TODO(bunnei): This can be replaced with C++20 waitable atomics when properly supported. // TODO(bunnei): This can be replaced with C++20 waitable atomics when properly supported.
// See discussion on https://github.com/yuzu-emu/yuzu/pull/3173 for details. // See discussion on https://github.com/yuzu-emu/yuzu/pull/3173 for details.
std::lock_guard lock{cv_mutex}; std::scoped_lock lock{cv_mutex};
cv.notify_one(); cv.notify_one();
} }
@ -159,7 +159,7 @@ public:
template <typename Arg> template <typename Arg>
void Push(Arg&& t) { void Push(Arg&& t) {
std::lock_guard lock{write_lock}; std::scoped_lock lock{write_lock};
spsc_queue.Push(t); spsc_queue.Push(t);
} }