Add timer start param to Application (RIPD 1405):

Modify doStart Application method to specify whether or not to start the
DeadlineTimers. Specify inactive timers for jtx::Env Applications and
active timers for standard Applications.
This commit is contained in:
Mike Ellery
2017-02-16 09:56:41 -08:00
committed by Scott Schurr
parent 7265729446
commit 95aebfc38c
4 changed files with 19 additions and 10 deletions

View File

@@ -363,6 +363,7 @@ public:
std::unique_ptr <TxQ> txQ_;
DeadlineTimer m_sweepTimer;
DeadlineTimer m_entropyTimer;
bool startTimers_;
std::unique_ptr <DatabaseCon> mTxnDB;
std::unique_ptr <DatabaseCon> mLedgerDB;
@@ -510,6 +511,8 @@ public:
, m_entropyTimer (this)
, startTimers_ (false)
, m_signals (get_io_service())
, checkSigs_(true)
@@ -545,7 +548,7 @@ public:
//--------------------------------------------------------------------------
bool setup() override;
void doStart() override;
void doStart(bool withTimers) override;
void run() override;
bool isShutdown() override;
void signalStop() override;
@@ -841,8 +844,11 @@ public:
<< "Application starting. Version is " << BuildInfo::getVersionString();
using namespace std::chrono_literals;
m_sweepTimer.setExpiration (10s);
m_entropyTimer.setRecurringExpiration (5min);
if(startTimers_)
{
m_sweepTimer.setExpiration (10s);
m_entropyTimer.setRecurringExpiration (5min);
}
m_io_latency_sampler.start();
@@ -871,9 +877,11 @@ public:
// things will happen.
m_resolver->stop ();
m_sweepTimer.cancel ();
m_entropyTimer.cancel ();
if(startTimers_)
{
m_sweepTimer.cancel ();
m_entropyTimer.cancel ();
}
mValidations->flush ();
@@ -1265,8 +1273,9 @@ bool ApplicationImp::setup()
}
void
ApplicationImp::doStart()
ApplicationImp::doStart(bool withTimers)
{
startTimers_ = withTimers;
prepare ();
start ();
}

View File

@@ -97,7 +97,7 @@ public:
virtual ~Application () = default;
virtual bool setup() = 0;
virtual void doStart() = 0;
virtual void doStart(bool withTimers) = 0;
virtual void run() = 0;
virtual bool isShutdown () = 0;
virtual void signalStop () = 0;

View File

@@ -461,7 +461,7 @@ int run (int argc, char** argv)
}
// Start the server
app->doStart();
app->doStart(true /*start timers*/);
// Block until we get a stop RPC.
app->run();

View File

@@ -143,7 +143,7 @@ Env::AppBundle::AppBundle(beast::unit_test::suite& suite,
Throw<std::runtime_error> ("Env::AppBundle: setup failed");
timeKeeper->set(
app->getLedgerMaster().getClosedLedger()->info().closeTime);
app->doStart();
app->doStart(false /*don't start timers*/);
thread = std::thread(
[&](){ app->run(); });