listenbrainz: added a listens synchronizer. fixes #142

This commit is contained in:
emeric
2021-04-30 17:41:03 +02:00
parent 8c5aee2e62
commit a6398738bb
33 changed files with 1359 additions and 363 deletions
+4 -32
View File
@@ -25,42 +25,14 @@
std::unique_ptr<IChildProcessManager>
createChildProcessManager()
createChildProcessManager(boost::asio::io_context& ioContext)
{
return std::make_unique<ChildProcessManager>();
return std::make_unique<ChildProcessManager>(ioContext);
}
ChildProcessManager::ChildProcessManager()
: _work {boost::asio::make_work_guard(_ioContext)}
ChildProcessManager::ChildProcessManager(boost::asio::io_context& ioContext)
: _ioContext {ioContext}
{
start();
}
ChildProcessManager::~ChildProcessManager()
{
stop();
}
void
ChildProcessManager::start()
{
LMS_LOG(CHILDPROCESS, INFO) << "Starting child process manager...";
_thread = std::make_unique<std::thread>([&]()
{
_ioContext.run();
});
LMS_LOG(CHILDPROCESS, INFO) << "Child process manager started!";
}
void
ChildProcessManager::stop()
{
LMS_LOG(CHILDPROCESS, INFO) << "Stopping child process manager";
_work.reset();
_thread->join();
LMS_LOG(CHILDPROCESS, INFO) << "Stopped child process manager";
}
std::unique_ptr<IChildProcess>