summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-08-14 11:28:59 +0200
committerGitHub <noreply@github.com>2021-08-14 11:28:59 +0200
commitbdd617da03526f94e72185fd96da93c5a2ae50cf (patch)
treedbb2d74fb6977b22e4cef4bd3658ba2f8060ae18 /src/common
parentMerge pull request #6862 from german77/badsdl (diff)
parentthreadsafe_queue: Fix deadlock (diff)
downloadyuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar.gz
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar.bz2
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar.lz
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar.xz
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.tar.zst
yuzu-bdd617da03526f94e72185fd96da93c5a2ae50cf.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/threadsafe_queue.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index ad04df8ca..8430b9778 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -46,15 +46,13 @@ public:
ElementPtr* new_ptr = new ElementPtr();
write_ptr->next.store(new_ptr, std::memory_order_release);
write_ptr = new_ptr;
+ ++size;
- const size_t previous_size{size++};
-
- // Acquire the mutex and then immediately release it as a fence.
+ // cv_mutex must be held or else there will be a missed wakeup if the other thread is in the
+ // line before cv.wait
// 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.
- if (previous_size == 0) {
- std::lock_guard lock{cv_mutex};
- }
+ std::lock_guard lock{cv_mutex};
cv.notify_one();
}