mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
Use Thread in LoadManager
This commit is contained in:
@@ -464,7 +464,7 @@ public:
|
|||||||
mSweepTimer.expires_from_now (boost::posix_time::seconds (10));
|
mSweepTimer.expires_from_now (boost::posix_time::seconds (10));
|
||||||
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
|
mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this));
|
||||||
|
|
||||||
m_loadManager->startThread ();
|
m_loadManager->start ();
|
||||||
|
|
||||||
#if ! BEAST_WIN32
|
#if ! BEAST_WIN32
|
||||||
#ifdef SIGINT
|
#ifdef SIGINT
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ SETUP_LOG (LoadManager)
|
|||||||
|
|
||||||
class LoadManagerImp
|
class LoadManagerImp
|
||||||
: public LoadManager
|
: public LoadManager
|
||||||
, public beast::InterruptibleThread::EntryPoint
|
, public Thread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* Entry mapping utilization to cost.
|
/* Entry mapping utilization to cost.
|
||||||
@@ -60,8 +60,8 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
LoadManagerImp ()
|
LoadManagerImp ()
|
||||||
: mLock (this, "LoadManagerImp", __FILE__, __LINE__)
|
: Thread ("loadmgr")
|
||||||
, m_thread ("loadmgr")
|
, mLock (this, "LoadManagerImp", __FILE__, __LINE__)
|
||||||
, m_logThread ("loadmgr_log")
|
, m_logThread ("loadmgr_log")
|
||||||
, mCreditRate (100)
|
, mCreditRate (100)
|
||||||
, mCreditLimit (500)
|
, mCreditLimit (500)
|
||||||
@@ -119,12 +119,12 @@ private:
|
|||||||
{
|
{
|
||||||
UptimeTimer::getInstance ().endManualUpdates ();
|
UptimeTimer::getInstance ().endManualUpdates ();
|
||||||
|
|
||||||
m_thread.interrupt ();
|
stopThread ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void startThread ()
|
void start ()
|
||||||
{
|
{
|
||||||
m_thread.start (this);
|
startThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
void canonicalize (LoadSource& source, int now) const
|
void canonicalize (LoadSource& source, int now) const
|
||||||
@@ -324,14 +324,14 @@ private:
|
|||||||
|
|
||||||
// VFALCO NOTE Where's the thread object? It's not a data member...
|
// VFALCO NOTE Where's the thread object? It's not a data member...
|
||||||
//
|
//
|
||||||
void threadRun ()
|
void run ()
|
||||||
{
|
{
|
||||||
// VFALCO TODO replace this with a beast Time object?
|
// VFALCO TODO replace this with a beast Time object?
|
||||||
//
|
//
|
||||||
// Initialize the clock to the current time.
|
// Initialize the clock to the current time.
|
||||||
boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time ();
|
boost::posix_time::ptime t = boost::posix_time::microsec_clock::universal_time ();
|
||||||
|
|
||||||
while (! m_thread.interruptionPoint ())
|
while (! threadShouldExit ())
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
// VFALCO NOTE What is this lock protecting?
|
// VFALCO NOTE What is this lock protecting?
|
||||||
@@ -413,7 +413,6 @@ private:
|
|||||||
typedef LockType::ScopedLockType ScopedLockType;
|
typedef LockType::ScopedLockType ScopedLockType;
|
||||||
LockType mLock;
|
LockType mLock;
|
||||||
|
|
||||||
beast::InterruptibleThread m_thread;
|
|
||||||
beast::ThreadWithCallQueue m_logThread;
|
beast::ThreadWithCallQueue m_logThread;
|
||||||
|
|
||||||
int mCreditRate; // credits gained/lost per second
|
int mCreditRate; // credits gained/lost per second
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
// VFALCO TODO Simplify the two stage initialization to one stage (construction).
|
// VFALCO TODO Simplify the two stage initialization to one stage (construction).
|
||||||
// NOTE In stand-alone mode the load manager thread isn't started
|
// NOTE In stand-alone mode the load manager thread isn't started
|
||||||
virtual void startThread () = 0;
|
virtual void start () = 0;
|
||||||
|
|
||||||
/** Turn on deadlock detection.
|
/** Turn on deadlock detection.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user