summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2019-12-17 02:39:53 +0100
committerbunnei <bunneidev@gmail.com>2019-12-17 02:39:53 +0100
commit67b8ecc73e4201ee98f812c2a43ff9e93414faea (patch)
tree65c329b4d04ae8c035e9d6003845240ff8f354e6
parentMerge pull request #3201 from lioncash/dump (diff)
downloadyuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar.gz
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar.bz2
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar.lz
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar.xz
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.tar.zst
yuzu-67b8ecc73e4201ee98f812c2a43ff9e93414faea.zip
Diffstat (limited to '')
-rw-r--r--src/common/threadsafe_queue.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index e714ba5b3..8268bbd5c 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -46,9 +46,16 @@ public:
ElementPtr* new_ptr = new ElementPtr();
write_ptr->next.store(new_ptr, std::memory_order_release);
write_ptr = new_ptr;
- cv.notify_one();
- ++size;
+ const size_t previous_size{size++};
+
+ // Acquire the mutex and then immediately release it as a fence.
+ // 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};
+ }
+ cv.notify_one();
}
void Pop() {