listenbrainz: added a listens synchronizer. fixes #142
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user