Fix SHAMapStore test timing consistency

This commit is contained in:
Edward Hennis
2016-03-11 14:04:21 -05:00
parent 30eff2b520
commit 8268162cac
4 changed files with 87 additions and 87 deletions

View File

@@ -180,7 +180,7 @@ SHAMapStoreImp::SHAMapStoreImp (
, scheduler_ (scheduler)
, journal_ (journal)
, nodeStoreJournal_ (nodeStoreJournal)
, rotating_(false)
, working_(true)
, transactionMaster_ (transactionMaster)
, canDelete_ (std::numeric_limits <LedgerIndex>::max())
{
@@ -251,10 +251,24 @@ SHAMapStoreImp::onLedgerClosed(
{
std::lock_guard <std::mutex> lock (mutex_);
newLedger_ = ledger;
working_ = true;
}
cond_.notify_one();
}
void
SHAMapStoreImp::rendezvous() const
{
if (!working_)
return;
std::unique_lock <std::mutex> lock(mutex_);
rendezvous_.wait(lock, [&]
{
return !working_;
});
}
bool
SHAMapStoreImp::copyNode (std::uint64_t& nodeCount,
SHAMapAbstractNode const& node)
@@ -288,10 +302,11 @@ SHAMapStoreImp::run()
{
healthy_ = true;
std::shared_ptr<Ledger const> validatedLedger;
rotating_ = false;
{
std::unique_lock <std::mutex> lock (mutex_);
working_ = false;
rendezvous_.notify_all();
if (stop_)
{
stopped();
@@ -300,7 +315,6 @@ SHAMapStoreImp::run()
cond_.wait (lock);
if (newLedger_)
{
rotating_ = true;
validatedLedger = std::move(newLedger_);
}
else