diff options
Diffstat (limited to 'src/common/threadsafe_queue.h')
| -rw-r--r-- | src/common/threadsafe_queue.h | 10 |
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: | |||
| 46 | ElementPtr* new_ptr = new ElementPtr(); | 46 | ElementPtr* new_ptr = new ElementPtr(); |
| 47 | write_ptr->next.store(new_ptr, std::memory_order_release); | 47 | write_ptr->next.store(new_ptr, std::memory_order_release); |
| 48 | write_ptr = new_ptr; | 48 | write_ptr = new_ptr; |
| 49 | ++size; | ||
| 49 | 50 | ||
| 50 | const size_t previous_size{size++}; | 51 | // cv_mutex must be held or else there will be a missed wakeup if the other thread is in the |
| 51 | 52 | // line before cv.wait | |
| 52 | // Acquire the mutex and then immediately release it as a fence. | ||
| 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 | if (previous_size == 0) { | 55 | std::lock_guard lock{cv_mutex}; |
| 56 | std::lock_guard lock{cv_mutex}; | ||
| 57 | } | ||
| 58 | cv.notify_one(); | 56 | cv.notify_one(); |
| 59 | } | 57 | } |
| 60 | 58 | ||