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() ...@@ -61,8 +61,7 @@ void DiscovererWorker::stop()
{ {
{ {
std::unique_lock<compat::Mutex> lock( m_mutex ); std::unique_lock<compat::Mutex> lock( m_mutex );
while ( m_tasks.empty() == false ) m_tasks.clear();
m_tasks.pop();
} }
m_cond.notify_all(); m_cond.notify_all();
m_thread.join(); m_thread.join();
...@@ -131,7 +130,7 @@ void DiscovererWorker::enqueue( const std::string& entryPoint, Task::Type type ) ...@@ -131,7 +130,7 @@ void DiscovererWorker::enqueue( const std::string& entryPoint, Task::Type type )
LOG_INFO( "Queuing global reload request" ); LOG_INFO( "Queuing global reload request" );
} }
m_tasks.emplace( entryPoint, type ); m_tasks.emplace_back( entryPoint, type );
notify(); notify();
} }
...@@ -144,7 +143,7 @@ void DiscovererWorker::enqueue( int64_t entityId, Task::Type type ) ...@@ -144,7 +143,7 @@ void DiscovererWorker::enqueue( int64_t entityId, Task::Type type )
LOG_INFO( "Queuing entity ", entityId, " of type ", LOG_INFO( "Queuing entity ", entityId, " of type ",
static_cast<typename std::underlying_type<Task::Type>::type>( type ) ); static_cast<typename std::underlying_type<Task::Type>::type>( type ) );
m_tasks.emplace( entityId, type ); m_tasks.emplace_back( entityId, type );
notify(); notify();
} }
...@@ -180,7 +179,7 @@ void DiscovererWorker::run() ...@@ -180,7 +179,7 @@ void DiscovererWorker::run()
m_ml->onDiscovererIdleChanged( false ); m_ml->onDiscovererIdleChanged( false );
} }
task = m_tasks.front(); task = m_tasks.front();
m_tasks.pop(); m_tasks.pop_front();
} }
switch ( task.type ) switch ( task.type )
{ {
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <atomic> #include <atomic>
#include "compat/ConditionVariable.h" #include "compat/ConditionVariable.h"
#include <memory> #include <memory>
#include <queue> #include <list>
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -100,7 +100,7 @@ private: ...@@ -100,7 +100,7 @@ private:
private: private:
compat::Thread m_thread; compat::Thread m_thread;
std::queue<Task> m_tasks; std::list<Task> m_tasks;
compat::Mutex m_mutex; compat::Mutex m_mutex;
compat::ConditionVariable m_cond; compat::ConditionVariable m_cond;
std::atomic_bool m_run; 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