WIP. Using WIOService to handle Services

This commit is contained in:
emeric
2014-08-05 13:11:31 +02:00
parent f26e6cad7c
commit 9fdc9f41dd
12 changed files with 148 additions and 65 deletions
+3 -15
View File
@@ -2,7 +2,7 @@
#include "DatabaseUpdateService.hpp"
DatabaseUpdateService::DatabaseUpdateService(boost::asio::io_service& ioService, const boost::filesystem::path& p)
DatabaseUpdateService::DatabaseUpdateService(const boost::filesystem::path& p)
: _metadataParser(),
_databaseUpdater( p, _metadataParser)
{
@@ -11,18 +11,14 @@ DatabaseUpdateService::DatabaseUpdateService(boost::asio::io_service& ioService,
void
DatabaseUpdateService::start(void)
{
// TODO
// Read database parameters and program a timer for the next scan
// _thread = boost::thread(boost::bind(&DatabaseUpdater::Updater::process, &_databaseUpdater));
_databaseUpdater.start();
}
void
DatabaseUpdateService::stop(void)
{
std::cout << "DatabaseUpdateService::stop, processing..." << std::endl;
// no effect if thread does not exist
_thread.interrupt();
_thread.join();
_databaseUpdater.stop();
std::cout << "DatabaseUpdateService::stop, process done" << std::endl;
}
@@ -34,11 +30,3 @@ DatabaseUpdateService::restart(void)
start();
}
bool
DatabaseUpdateService::isScanning(void) const
{
// scanning is active only if a thread is running the updater
return _thread.get_id() != boost::thread::id();
}