Commit cf45a5c1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

ParserWorker: Don't mandate the parser to be paused before flushing

Fix #374
parent 8080ac7f
...@@ -114,7 +114,6 @@ void Parser::flush() ...@@ -114,7 +114,6 @@ void Parser::flush()
void Parser::prepareRescan() void Parser::prepareRescan()
{ {
pause();
flush(); flush();
} }
...@@ -160,17 +159,8 @@ void Parser::onDeviceDisappearing( int64_t ) ...@@ -160,17 +159,8 @@ void Parser::onDeviceDisappearing( int64_t )
void Parser::refreshTaskList() void Parser::refreshTaskList()
{ {
/*
* We need to do this in various steps:
* - Pausing the workers after their currently running task
* - Flushing their task list
* - Restoring the task list from DB
* - Resuming the workers
*/
pause();
flush(); flush();
restore(); restore();
resume();
} }
void Parser::updateStats() void Parser::updateStats()
......
...@@ -153,10 +153,6 @@ bool Worker::isIdle() const ...@@ -153,10 +153,6 @@ bool Worker::isIdle() const
void Worker::flush() void Worker::flush()
{ {
std::unique_lock<compat::Mutex> lock( m_lock ); std::unique_lock<compat::Mutex> lock( m_lock );
assert( m_paused == true || m_thread.get_id() == compat::Thread::id{} );
m_idleCond.wait( lock, [this]() {
return m_idle == true;
});
while ( m_tasks.empty() == false ) while ( m_tasks.empty() == false )
m_tasks.pop(); m_tasks.pop();
m_service->onFlushing(); m_service->onFlushing();
...@@ -189,7 +185,6 @@ void Worker::mainloop() ...@@ -189,7 +185,6 @@ void Worker::mainloop()
{ {
LOG_DEBUG( "Halting ParserService [", serviceName, "] mainloop" ); LOG_DEBUG( "Halting ParserService [", serviceName, "] mainloop" );
setIdle( true ); setIdle( true );
m_idleCond.notify_all();
m_cond.wait( lock, [this]() { m_cond.wait( lock, [this]() {
return ( m_tasks.empty() == false && m_paused == false ) return ( m_tasks.empty() == false && m_paused == false )
|| m_stopParser == true; || m_stopParser == true;
......
...@@ -99,7 +99,6 @@ private: ...@@ -99,7 +99,6 @@ private:
bool m_paused; bool m_paused;
std::atomic_bool m_idle; std::atomic_bool m_idle;
compat::ConditionVariable m_cond; compat::ConditionVariable m_cond;
compat::ConditionVariable m_idleCond;
std::queue<std::shared_ptr<Task>> m_tasks; std::queue<std::shared_ptr<Task>> m_tasks;
compat::Thread m_thread; compat::Thread m_thread;
compat::Mutex m_lock; compat::Mutex m_lock;
......
Supports Markdown
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