diff options
| author | JMC47 <JMC4789@gmail.com> | 2025-10-30 19:26:22 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-30 19:26:22 -0400 |
| commit | d065f1ae1228203b354c35ca853f36fa45a59c43 (patch) | |
| tree | b6109e5c827759de2db293d24a4ed4f545f2d9e6 /Source/Core/VideoCommon/AsyncRequests.cpp | |
| parent | ccc334cdd023ed774a89b8a207cc29e0beaf88fd (diff) | |
| parent | 09a125fec4ba077006bc0add7a8bfcdc0a572bc9 (diff) | |
Merge pull request #14041 from jordan-woyak/lockless-async-requests
VideoCommon: Clean up and eliminate the mutex in AsyncRequests.
Diffstat (limited to 'Source/Core/VideoCommon/AsyncRequests.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/AsyncRequests.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index 6671f93293..7348724e43 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -3,8 +3,6 @@ #include "VideoCommon/AsyncRequests.h" -#include <mutex> - #include "Core/System.h" #include "VideoCommon/Fifo.h" @@ -16,33 +14,25 @@ AsyncRequests AsyncRequests::s_singleton; AsyncRequests::AsyncRequests() = default; -void AsyncRequests::PullEventsInternal() +void AsyncRequests::PullEvents() { + if (m_queue.Empty()) + return; + // This is only called if the queue isn't empty. // So just flush the pipeline to get accurate results. g_vertex_manager->Flush(); - std::unique_lock<std::mutex> lock(m_mutex); - m_empty.Set(); - - while (!m_queue.empty()) + while (!m_queue.Empty()) { - Event e = std::move(m_queue.front()); - lock.unlock(); - std::invoke(e); - lock.lock(); - - m_queue.pop(); + std::invoke(std::move(m_queue.Front())); + m_queue.Pop(); } - - m_cond.notify_one(); } void AsyncRequests::QueueEvent(Event&& event) { - m_empty.Clear(); - - m_queue.push(std::move(event)); + m_queue.Push(std::move(event)); auto& system = Core::System::GetInstance(); system.GetFifo().RunGpu(); @@ -50,12 +40,10 @@ void AsyncRequests::QueueEvent(Event&& event) void AsyncRequests::WaitForEmptyQueue() { - std::unique_lock<std::mutex> lock(m_mutex); - m_cond.wait(lock, [this] { return m_queue.empty(); }); + m_queue.WaitForEmpty(); } void AsyncRequests::SetPassthrough(bool enable) { - std::unique_lock<std::mutex> lock(m_mutex); m_passthrough = enable; } |
