mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Split LoadEvent to a new file
This commit is contained in:
@@ -1022,6 +1022,7 @@ void LedgerConsensus::playbackProposals()
|
||||
}
|
||||
}
|
||||
|
||||
// VFALCO: TODO, clean these macros up and put them somewhere. Try to eliminate them if possible.
|
||||
#define LCAT_SUCCESS 0
|
||||
#define LCAT_FAIL 1
|
||||
#define LCAT_RETRY 2
|
||||
@@ -1040,6 +1041,7 @@ int LedgerConsensus::applyTransaction(TransactionEngine& engine, SerializedTrans
|
||||
<< (retryAssured ? "/retry" : "/final");
|
||||
WriteLog (lsTRACE, LedgerConsensus) << txn->getJson(0);
|
||||
|
||||
// VFALCO: TODO, figure out what this "trust network" is all about and why it needs exceptions.
|
||||
#ifndef TRUST_NETWORK
|
||||
try
|
||||
{
|
||||
|
||||
@@ -55,51 +55,4 @@ private:
|
||||
boost::mutex mLock;
|
||||
};
|
||||
|
||||
class LoadEvent
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<LoadEvent> pointer;
|
||||
typedef UPTR_T<LoadEvent> autoptr;
|
||||
|
||||
public:
|
||||
LoadEvent(LoadMonitor& monitor, const std::string& name, bool shouldStart) :
|
||||
mMonitor(monitor), mRunning(false), mName(name)
|
||||
{
|
||||
mStartTime = boost::posix_time::microsec_clock::universal_time();
|
||||
if (shouldStart)
|
||||
start();
|
||||
}
|
||||
|
||||
~LoadEvent()
|
||||
{
|
||||
if (mRunning)
|
||||
stop();
|
||||
}
|
||||
|
||||
void reName(const std::string& name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
void start()
|
||||
{ // okay to call if already started
|
||||
mRunning = true;
|
||||
mStartTime = boost::posix_time::microsec_clock::universal_time();
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
assert(mRunning);
|
||||
mRunning = false;
|
||||
mMonitor.addCountAndLatency(mName,
|
||||
static_cast<int>((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds()));
|
||||
}
|
||||
|
||||
private:
|
||||
LoadMonitor& mMonitor;
|
||||
bool mRunning;
|
||||
std::string mName;
|
||||
boost::posix_time::ptime mStartTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
37
src/cpp/ripple/ripple_LoadEvent.cpp
Normal file
37
src/cpp/ripple/ripple_LoadEvent.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
LoadEvent::LoadEvent (LoadMonitor& monitor, const std::string& name, bool shouldStart)
|
||||
: mMonitor (monitor)
|
||||
, mRunning (false)
|
||||
, mName (name)
|
||||
{
|
||||
mStartTime = boost::posix_time::microsec_clock::universal_time();
|
||||
|
||||
if (shouldStart)
|
||||
start();
|
||||
}
|
||||
|
||||
LoadEvent::~LoadEvent()
|
||||
{
|
||||
if (mRunning)
|
||||
stop();
|
||||
}
|
||||
|
||||
void LoadEvent::reName(const std::string& name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
void LoadEvent::start()
|
||||
{
|
||||
mRunning = true;
|
||||
mStartTime = boost::posix_time::microsec_clock::universal_time();
|
||||
}
|
||||
|
||||
void LoadEvent::stop()
|
||||
{
|
||||
assert(mRunning);
|
||||
|
||||
mRunning = false;
|
||||
mMonitor.addCountAndLatency (mName,
|
||||
static_cast<int>((boost::posix_time::microsec_clock::universal_time() - mStartTime).total_milliseconds()));
|
||||
}
|
||||
35
src/cpp/ripple/ripple_LoadEvent.h
Normal file
35
src/cpp/ripple/ripple_LoadEvent.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef RIPPLE_LOADEVENT_H
|
||||
#define RIPPLE_LOADEVENT_H
|
||||
|
||||
class LoadMonitor;
|
||||
|
||||
class LoadEvent
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<LoadEvent> pointer;
|
||||
typedef UPTR_T<LoadEvent> autoptr;
|
||||
|
||||
public:
|
||||
// VFALCO: TODO, remove the dependency on LoadMonitor.
|
||||
LoadEvent (LoadMonitor& monitor,
|
||||
const std::string& name,
|
||||
bool shouldStart);
|
||||
|
||||
~LoadEvent();
|
||||
|
||||
// VFALCO: TODO, rename this to setName () or setLabel ()
|
||||
void reName (const std::string& name);
|
||||
|
||||
// okay to call if already started
|
||||
void start();
|
||||
|
||||
void stop();
|
||||
|
||||
private:
|
||||
LoadMonitor& mMonitor;
|
||||
bool mRunning;
|
||||
std::string mName;
|
||||
boost::posix_time::ptime mStartTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user