Commit b4fd6120 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

DiscovererWorker: Use a task list instead of a queue

Since we will soon start inserting at the front or in the middle of
the task list
parent 004d1e8b
......@@ -61,8 +61,7 @@ void DiscovererWorker::stop()
{
{
std::unique_lock<compat::Mutex> lock( m_mutex );
while ( m_tasks.empty() == false )
m_tasks.pop();
m_tasks.clear();
}
m_cond.notify_all();
m_thread.join();
......@@ -131,7 +130,7 @@ void DiscovererWorker::enqueue( const std::string& entryPoint, Task::Type type )
LOG_INFO( "Queuing global reload request" );
}
m_tasks.emplace( entryPoint, type );
m_tasks.emplace_back( entryPoint, type );
notify();
}
......@@ -144,7 +143,7 @@ void DiscovererWorker::enqueue( int64_t entityId, Task::Type type )
LOG_INFO( "Queuing entity ", entityId, " of type ",
static_cast<typename std::underlying_type<Task::Type>::type>( type ) );
m_tasks.emplace( entityId, type );
m_tasks.emplace_back( entityId, type );
notify();
}
......@@ -180,7 +179,7 @@ void DiscovererWorker::run()
m_ml->onDiscovererIdleChanged( false );
}
task = m_tasks.front();
m_tasks.pop();
m_tasks.pop_front();
}
switch ( task.type )
{
......
......@@ -25,7 +25,7 @@
#include <atomic>
#include "compat/ConditionVariable.h"
#include <memory>
#include <queue>
#include <list>
#include <string>
#include <vector>
......@@ -100,7 +100,7 @@ private:
private:
compat::Thread m_thread;
std::queue<Task> m_tasks;
std::list<Task> m_tasks;
compat::Mutex m_mutex;
compat::ConditionVariable m_cond;
std::atomic_bool m_run;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment