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

parser: Rename old ParserService to ParserWorker

parent 83f3c95c
......@@ -83,7 +83,7 @@ libmedialibrary_la_SOURCES = \
src/metadata_services/vlc/VLCMetadataService.cpp \
src/metadata_services/vlc/VLCThumbnailer.cpp \
src/parser/Parser.cpp \
src/parser/ParserService.cpp \
src/parser/ParserWorker.cpp \
src/parser/Task.cpp \
src/utils/Directory.cpp \
src/utils/Filename.cpp \
......@@ -150,7 +150,7 @@ noinst_HEADERS = \
src/Movie.h \
src/parser/IParserService.h \
src/parser/Parser.h \
src/parser/ParserService.h \
src/parser/ParserWorker.h \
src/parser/Task.h \
src/Playlist.h \
src/Settings.h \
......
......@@ -35,7 +35,7 @@ namespace medialibrary
class ModificationNotifier;
class DiscovererWorker;
class Parser;
class ParserService;
class ParserWorker;
class VLCThumbnailer;
class Album;
......
......@@ -23,7 +23,7 @@
#pragma once
#include "MediaLibrary.h"
#include "parser/ParserService.h"
#include "parser/ParserWorker.h"
namespace medialibrary
{
......
......@@ -27,7 +27,7 @@
#include <vlcpp/vlc.hpp>
#include "imagecompressors/IImageCompressor.h"
#include "parser/ParserService.h"
#include "parser/ParserWorker.h"
namespace medialibrary
{
......
......@@ -32,7 +32,7 @@
#include "medialibrary/IMediaLibrary.h"
#include "Media.h"
#include "File.h"
#include "ParserService.h"
#include "ParserWorker.h"
namespace medialibrary
{
......@@ -53,7 +53,7 @@ Parser::~Parser()
void Parser::addService( ServicePtr service )
{
auto worker = std::make_unique<ParserService>();
auto worker = std::make_unique<ParserWorker>();
worker->initialize( m_ml, this, std::move( service ) );
m_services.push_back( std::move( worker ) );
}
......
......@@ -32,7 +32,7 @@ namespace medialibrary
{
class IParserService;
class ParserService;
class ParserWorker;
// Use an interface to expose only the "done" method
class IParserCb
......@@ -47,6 +47,7 @@ class Parser : IParserCb
{
public:
using ServicePtr = std::unique_ptr<IParserService>;
using WorkerPtr = std::unique_ptr<ParserWorker>;
Parser( MediaLibrary* ml );
virtual ~Parser();
......@@ -73,7 +74,7 @@ private:
virtual void onIdleChanged( bool idle ) override;
private:
typedef std::vector<std::unique_ptr<ParserService>> ServiceList;
typedef std::vector<WorkerPtr> ServiceList;
private:
ServiceList m_services;
......
......@@ -24,14 +24,14 @@
# include "config.h"
#endif
#include "ParserService.h"
#include "ParserWorker.h"
#include "Parser.h"
#include "Media.h"
namespace medialibrary
{
ParserService::ParserService()
ParserWorker::ParserWorker()
: m_parserCb( nullptr )
, m_stopParser( false )
, m_paused( false )
......@@ -39,28 +39,28 @@ ParserService::ParserService()
{
}
void ParserService::start()
void ParserWorker::start()
{
// Ensure we don't start multiple times.
assert( m_threads.size() == 0 );
for ( auto i = 0u; i < m_service->nbThreads(); ++i )
m_threads.emplace_back( &ParserService::mainloop, this );
m_threads.emplace_back( &ParserWorker::mainloop, this );
}
void ParserService::pause()
void ParserWorker::pause()
{
std::lock_guard<compat::Mutex> lock( m_lock );
m_paused = true;
}
void ParserService::resume()
void ParserWorker::resume()
{
std::lock_guard<compat::Mutex> lock( m_lock );
m_paused = false;
m_cond.notify_all();
}
void ParserService::signalStop()
void ParserWorker::signalStop()
{
for ( auto& t : m_threads )
{
......@@ -73,7 +73,7 @@ void ParserService::signalStop()
}
}
void ParserService::stop()
void ParserWorker::stop()
{
for ( auto& t : m_threads )
{
......@@ -82,7 +82,7 @@ void ParserService::stop()
}
}
void ParserService::parse( std::shared_ptr<parser::Task> t )
void ParserWorker::parse( std::shared_ptr<parser::Task> t )
{
if ( m_threads.size() == 0 )
{
......@@ -98,7 +98,7 @@ void ParserService::parse( std::shared_ptr<parser::Task> t )
}
}
void ParserService::initialize( MediaLibrary* ml, IParserCb* parserCb, std::unique_ptr<IParserService> service )
void ParserWorker::initialize( MediaLibrary* ml, IParserCb* parserCb, std::unique_ptr<IParserService> service )
{
m_service = std::move( service );
m_parserCb = parserCb;
......@@ -106,12 +106,12 @@ void ParserService::initialize( MediaLibrary* ml, IParserCb* parserCb, std::uniq
m_service->initialize( ml );
}
bool ParserService::isIdle() const
bool ParserWorker::isIdle() const
{
return m_idle;
}
void ParserService::flush()
void ParserWorker::flush()
{
std::unique_lock<compat::Mutex> lock( m_lock );
assert( m_paused == true || m_threads.empty() == true );
......@@ -123,12 +123,12 @@ void ParserService::flush()
m_service->onFlushing();
}
void ParserService::restart()
void ParserWorker::restart()
{
m_service->onRestarted();
}
void ParserService::mainloop()
void ParserWorker::mainloop()
{
// It would be unsafe to call name() at the end of this function, since
// we might stop the thread during ParserService destruction. This implies
......@@ -196,7 +196,7 @@ void ParserService::mainloop()
setIdle( true );
}
void ParserService::setIdle(bool isIdle)
void ParserWorker::setIdle(bool isIdle)
{
// Calling the idleChanged callback will trigger a call to isIdle, so set the value before
// invoking it, otherwise we have an incoherent state.
......
......@@ -40,10 +40,10 @@ class IParserCb;
class ModificationNotifier;
class MediaLibrary;
class ParserService
class ParserWorker
{
public:
ParserService();
ParserWorker();
void pause();
void resume();
......
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