mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-04-24 21:40:53 +00:00
VideoCommon: remove template parameter from lock guards in AsyncShaderCompiler, let type deduction do its thing and improve readability
This commit is contained in:
parent
75c66e35c6
commit
506e378289
@ -35,7 +35,7 @@ void AsyncShaderCompiler::QueueWorkItem(WorkItemPtr item, u32 priority)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_work_lock);
|
||||
std::lock_guard guard(m_pending_work_lock);
|
||||
m_pending_work.emplace(priority, std::move(item));
|
||||
m_worker_thread_wake.notify_one();
|
||||
}
|
||||
@ -45,7 +45,7 @@ void AsyncShaderCompiler::RetrieveWorkItems()
|
||||
{
|
||||
std::deque<WorkItemPtr> completed_work;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_completed_work_lock);
|
||||
std::lock_guard guard(m_completed_work_lock);
|
||||
m_completed_work.swap(completed_work);
|
||||
}
|
||||
|
||||
@ -58,25 +58,25 @@ void AsyncShaderCompiler::RetrieveWorkItems()
|
||||
|
||||
bool AsyncShaderCompiler::HasPendingWork()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_work_lock);
|
||||
std::lock_guard guard(m_pending_work_lock);
|
||||
return !m_pending_work.empty() || m_busy_workers.load() != 0;
|
||||
}
|
||||
|
||||
bool AsyncShaderCompiler::HasCompletedWork()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_completed_work_lock);
|
||||
std::lock_guard guard(m_completed_work_lock);
|
||||
return !m_completed_work.empty();
|
||||
}
|
||||
|
||||
void AsyncShaderCompiler::ClearAllWork()
|
||||
{
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_work_lock);
|
||||
std::lock_guard guard(m_pending_work_lock);
|
||||
m_pending_work.clear();
|
||||
}
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_completed_work_lock);
|
||||
std::lock_guard guard(m_completed_work_lock);
|
||||
m_completed_work.clear();
|
||||
}
|
||||
}
|
||||
@ -102,8 +102,8 @@ bool AsyncShaderCompiler::WaitUntilCompletion(
|
||||
size_t total_items;
|
||||
{
|
||||
// Safe to hold both locks here, since nowhere else does.
|
||||
std::lock_guard<std::mutex> pending_guard(m_pending_work_lock);
|
||||
std::lock_guard<std::mutex> completed_guard(m_completed_work_lock);
|
||||
std::lock_guard pending_guard(m_pending_work_lock);
|
||||
std::lock_guard completed_guard(m_completed_work_lock);
|
||||
total_items = m_completed_work.size() + m_pending_work.size() + m_busy_workers.load() + 1;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ bool AsyncShaderCompiler::WaitUntilCompletion(
|
||||
{
|
||||
size_t remaining_items;
|
||||
{
|
||||
std::lock_guard<std::mutex> pending_guard(m_pending_work_lock);
|
||||
std::lock_guard pending_guard(m_pending_work_lock);
|
||||
if (m_pending_work.empty() && !m_busy_workers.load())
|
||||
return true;
|
||||
remaining_items = m_pending_work.size();
|
||||
@ -177,7 +177,7 @@ void AsyncShaderCompiler::StopWorkerThreads()
|
||||
|
||||
// Signal worker threads to stop, and wake all of them.
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(m_pending_work_lock);
|
||||
std::lock_guard guard(m_pending_work_lock);
|
||||
m_exit_flag.Set();
|
||||
m_worker_thread_wake.notify_all();
|
||||
}
|
||||
@ -226,7 +226,7 @@ void AsyncShaderCompiler::WorkerThreadEntryPoint(void* param)
|
||||
|
||||
void AsyncShaderCompiler::WorkerThreadRun()
|
||||
{
|
||||
std::unique_lock<std::mutex> pending_lock(m_pending_work_lock);
|
||||
std::unique_lock pending_lock(m_pending_work_lock);
|
||||
while (!m_exit_flag.IsSet())
|
||||
{
|
||||
m_worker_thread_wake.wait(pending_lock);
|
||||
@ -241,7 +241,7 @@ void AsyncShaderCompiler::WorkerThreadRun()
|
||||
|
||||
if (item->Compile())
|
||||
{
|
||||
std::lock_guard<std::mutex> completed_guard(m_completed_work_lock);
|
||||
std::lock_guard completed_guard(m_completed_work_lock);
|
||||
m_completed_work.push_back(std::move(item));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user