Redesign stoppable object pattern

This commit is contained in:
John Freeman
2021-05-26 17:45:41 -05:00
committed by manojsdoshi
parent c10c0be11b
commit a2a37a928a
92 changed files with 781 additions and 2460 deletions

View File

@@ -303,20 +303,16 @@ PerfLogImp::report()
PerfLogImp::PerfLogImp(
Setup const& setup,
Stoppable& parent,
beast::Journal journal,
std::function<void()>&& signalStop)
: Stoppable("PerfLogImp", parent)
, setup_(setup)
, j_(journal)
, signalStop_(std::move(signalStop))
: setup_(setup), j_(journal), signalStop_(std::move(signalStop))
{
openLog();
}
PerfLogImp::~PerfLogImp()
{
onStop();
stop();
}
void
@@ -448,14 +444,14 @@ PerfLogImp::rotate()
}
void
PerfLogImp::onStart()
PerfLogImp::start()
{
if (setup_.perfLog.size())
thread_ = std::thread(&PerfLogImp::run, this);
}
void
PerfLogImp::onStop()
PerfLogImp::stop()
{
if (thread_.joinable())
{
@@ -468,12 +464,6 @@ PerfLogImp::onStop()
}
}
void
PerfLogImp::onChildrenStopped()
{
stopped();
}
//-----------------------------------------------------------------------------
PerfLog::Setup
@@ -501,12 +491,10 @@ setup_PerfLog(Section const& section, boost::filesystem::path const& configDir)
std::unique_ptr<PerfLog>
make_PerfLog(
PerfLog::Setup const& setup,
Stoppable& parent,
beast::Journal journal,
std::function<void()>&& signalStop)
{
return std::make_unique<PerfLogImp>(
setup, parent, journal, std::move(signalStop));
return std::make_unique<PerfLogImp>(setup, journal, std::move(signalStop));
}
} // namespace perf