diff --git a/modules/ripple_core/functional/ripple_Job.cpp b/modules/ripple_core/functional/ripple_Job.cpp index 7669fb1d81..18d6a6a162 100644 --- a/modules/ripple_core/functional/ripple_Job.cpp +++ b/modules/ripple_core/functional/ripple_Job.cpp @@ -40,15 +40,9 @@ JobType Job::getType () const void Job::doJob () { - m_loadEvent->start (); + m_loadEvent->reName (mName); mJob (*this); - - // VFALCO TODO Isn't there a way to construct the load event with - // the proper name? This way the load event object - // can have the invariant "name is always set" - // - m_loadEvent->reName (mName); } void Job::rename (std::string const& newName) @@ -61,6 +55,11 @@ int Job::getLimit () const return m_limit; } +LoadEvent& Job::peekEvent() const +{ + return *m_loadEvent; +} + const char* Job::toString (JobType t) { switch (t) diff --git a/modules/ripple_core/functional/ripple_Job.h b/modules/ripple_core/functional/ripple_Job.h index 55d54f2f3e..66106f3e6e 100644 --- a/modules/ripple_core/functional/ripple_Job.h +++ b/modules/ripple_core/functional/ripple_Job.h @@ -81,6 +81,8 @@ public: int getLimit () const; + LoadEvent& peekEvent() const; + // These comparison operators make the jobs sort in priority order in the job set bool operator< (const Job& j) const; bool operator> (const Job& j) const; diff --git a/modules/ripple_core/functional/ripple_JobQueue.cpp b/modules/ripple_core/functional/ripple_JobQueue.cpp index 5d88673ea0..30e0e52df1 100644 --- a/modules/ripple_core/functional/ripple_JobQueue.cpp +++ b/modules/ripple_core/functional/ripple_JobQueue.cpp @@ -44,7 +44,9 @@ void JobQueue::addLimitJob (JobType type, const std::string& name, int limit, co if (type != jtCLIENT) // FIXME: Workaround incorrect client shutdown ordering assert (mThreadCount != 0); // do not add jobs to a queue with no threads - mJobSet.insert (Job (type, name, limit, ++mLastJob, mJobLoads[type], jobFunc)); + std::pair< std::set ::iterator, bool > it = + mJobSet.insert (Job (type, name, limit, ++mLastJob, mJobLoads[type], jobFunc)); + it.first->peekEvent().start(); // start timing how long it stays in the queue ++mJobCounts[type].first; mJobCond.notify_one (); }