Skip to content
Permalink
Browse files

Merge pull request #8395 from CookiePLMonster/improve-work-queue

Improvements to WorkQueueThread
  • Loading branch information...
JMC47 committed Oct 13, 2019
2 parents aba23c8 + 26ebf5b commit d39555919d39357b49a7eb02f2d96b9a71bf128b
Showing with 9 additions and 10 deletions.
  1. +9 −10 Source/Core/Common/WorkQueueThread.h
@@ -27,14 +27,14 @@ class WorkQueueThread
Shutdown();
m_shutdown.Clear();
m_function = std::move(function);
m_thread = std::thread([this] { ThreadLoop(); });
m_thread = std::thread(&WorkQueueThread::ThreadLoop, this);
}

template <typename... Args>
void EmplaceItem(Args&&... args)
{
{
std::unique_lock<std::mutex> lg(m_lock);
std::lock_guard lg(m_lock);
m_items.emplace(std::forward<Args>(args)...);
}
m_wakeup.Set();
@@ -59,14 +59,13 @@ class WorkQueueThread

while (true)
{
T item;
{
std::unique_lock<std::mutex> lg(m_lock);
if (m_items.empty())
break;
item = m_items.front();
m_items.pop();
}
std::unique_lock lg(m_lock);
if (m_items.empty())
break;
T item{std::move(m_items.front())};
m_items.pop();
lg.unlock();

m_function(std::move(item));
}

0 comments on commit d395559

Please sign in to comment.
You can’t perform that action at this time.