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()
void Parser::prepareRescan()
{
pause();
flush();
}
......@@ -160,17 +159,8 @@ void Parser::onDeviceDisappearing( int64_t )
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();
restore();
resume();
}
void Parser::updateStats()
......
......@@ -153,10 +153,6 @@ bool Worker::isIdle() const
void Worker::flush()
{
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 )
m_tasks.pop();
m_service->onFlushing();
......@@ -189,7 +185,6 @@ void Worker::mainloop()
{
LOG_DEBUG( "Halting ParserService [", serviceName, "] mainloop" );
setIdle( true );
m_idleCond.notify_all();
m_cond.wait( lock, [this]() {
return ( m_tasks.empty() == false && m_paused == false )
|| m_stopParser == true;
......
......@@ -99,7 +99,6 @@ private:
bool m_paused;
std::atomic_bool m_idle;
compat::ConditionVariable m_cond;
compat::ConditionVariable m_idleCond;
std::queue<std::shared_ptr<Task>> m_tasks;
compat::Thread m_thread;
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