Clean-up the Stoppable architecture

This commit is contained in:
John Freeman
2020-12-04 14:19:54 -06:00
committed by Edward Hennis
parent 1fd1c34112
commit 78245a072c
17 changed files with 106 additions and 198 deletions

View File

@@ -150,7 +150,7 @@ SHAMapStoreImp::SHAMapStoreImp(
Stoppable& parent,
NodeStore::Scheduler& scheduler,
beast::Journal journal)
: SHAMapStore(parent)
: Stoppable("SHAMapStore", parent)
, app_(app)
, scheduler_(scheduler)
, journal_(journal)
@@ -731,6 +731,7 @@ SHAMapStoreImp::health()
void
SHAMapStoreImp::onStop()
{
// This is really a check for `if (thread_)`.
if (deleteInterval_)
{
{
@@ -738,26 +739,12 @@ SHAMapStoreImp::onStop()
stop_ = true;
}
cond_.notify_one();
// stopped() will be called by the thread_ running run(),
// when it reaches the check for stop_.
}
else
{
stopped();
}
}
void
SHAMapStoreImp::onChildrenStopped()
{
if (deleteInterval_)
{
{
std::lock_guard lock(mutex_);
stop_ = true;
}
cond_.notify_one();
}
else
{
// There is no thread running run(), so we must call stopped().
stopped();
}
}