Refactor Application shutdown using new Service, AsyncService interfaces

This commit is contained in:
Vinnie Falco
2013-09-17 17:32:54 -07:00
parent 97e961a048
commit 89b1859929
57 changed files with 2690 additions and 1602 deletions

View File

@@ -89,8 +89,9 @@ private:
typedef boost::unordered_map<std::pair< std::string, int>, score> epScore;
public:
UniqueNodeListImp ()
: mFetchLock (this, "Fetch", __FILE__, __LINE__)
explicit UniqueNodeListImp (Service& parent)
: UniqueNodeList (parent)
, mFetchLock (this, "Fetch", __FILE__, __LINE__)
, mUNLLock (this, "UNL", __FILE__, __LINE__)
, m_scoreTimer (this)
, mFetchActive (0)
@@ -100,6 +101,16 @@ public:
//--------------------------------------------------------------------------
void onServiceStop ()
{
m_fetchTimer.cancel ();
m_scoreTimer.cancel ();
serviceStopped ();
}
//--------------------------------------------------------------------------
void doScore ()
{
mtpScoreNext = boost::posix_time::ptime (boost::posix_time::not_a_date_time); // Timer not set.
@@ -1150,17 +1161,6 @@ private:
//--------------------------------------------------------------------------
// Begin scoring if timer was not cancelled.
void scoreTimerHandler (const boost::system::error_code& err)
{
if (!err)
{
onDeadlineTimer (m_scoreTimer);
}
}
//--------------------------------------------------------------------------
// Start a timer to update scores.
// <-- bNow: true, to force scoring for debugging.
void scoreNext (bool bNow)
@@ -2052,9 +2052,6 @@ private:
% getConfig ().VALIDATORS_BASE);
}
}
//--------------------------------------------------------------------------
private:
typedef RippleMutex FetchLockType;
typedef FetchLockType::ScopedLockType ScopedFetchLockType;
@@ -2085,7 +2082,16 @@ private:
std::map<RippleAddress, ClusterNodeStatus> m_clusterNodes;
};
UniqueNodeList* UniqueNodeList::New ()
//------------------------------------------------------------------------------
UniqueNodeList::UniqueNodeList (Service& parent)
: Service ("UniqueNodeList", parent)
{
return new UniqueNodeListImp ();
}
//------------------------------------------------------------------------------
UniqueNodeList* UniqueNodeList::New (Service& parent)
{
return new UniqueNodeListImp (parent);
}