Split LoadEvent to a new file

This commit is contained in:
Vinnie Falco
2013-06-03 07:39:49 -07:00
parent 32a3024ce4
commit 3f3c76ab7e
7 changed files with 93 additions and 51 deletions

View 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()));
}