void lock() { mTimesAcquired++; preLockTimer += curClock() - mUnlockStartTime; mLock.lock(); postLockTimer += curClock() - mUnlockStartTime; }
~TimedLock() { if (curClock() - preLockTimer > mTimeout) LOG_WARN << mLockType << " mLock held for " << curClock() - postLockTimer << " over " << mTimesAcquired << " instances. acquiring took " << postLockTimer - preLockTimer << ". trace =\n" << Ufora::debug::StackTrace::getStringTrace(); }
TimedLock(boost::recursive_mutex& m, const char* lockType, double timeout = 1.0) : preLockTimer(curClock()), mLock(m), postLockTimer(curClock()), mLockType(lockType), mTimeout(timeout), mUnlockStartTime(0), mTimesAcquired(1) { }
bool tryToReplaceTableWithSize(long newSize, key_type key, value_type value) { UnresizableFourLookupHashTable<key_type, value_type>* newTable = new UnresizableFourLookupHashTable<key_type, value_type>(newSize); if (!mTable->hashInto(*newTable) || !newTable->insert(key, value)) { delete newTable; return false; } UnresizableFourLookupHashTable<key_type, value_type>* oldTable = mTable; mTable = newTable; if (threadsafe) //schedule this to be deleted on a background thread at some point in the future fourLookupHashTableDeletionCallbackScheduler()->schedule( boost::bind(deleteTable, oldTable), curClock() + .1 ); else delete oldTable; return true; }
ScopedPythonTracer::ScopedPythonTracer(boost::python::object inObject) { mCalledPythonObject = inObject; mCreationTime = curClock(); mEnclosingScope = sCurrentTracer; sCurrentTracer = this; mTimeSpentByChildren = 0; }
~Scope() { ScopedTimingAccumulator old = mAccumulator; mAccumulator.observe(curClock() - mT0); mCallback(old, mAccumulator); }
ScopedPythonTracer::~ScopedPythonTracer() { boost::recursive_mutex::scoped_lock lock(sMutex); double finTime = curClock(); double totalTimeWithin = finTime - mCreationTime; sObjectEntrytimes[mCalledPythonObject].observe(totalTimeWithin - mTimeSpentByChildren, 1.0); if (mEnclosingScope) mEnclosingScope->mTimeSpentByChildren += totalTimeWithin; sCurrentTracer = mEnclosingScope; }
Scope(ScopedTimingAccumulator& accumulator, const callback_type& callback) : mT0(curClock()), mAccumulator(accumulator), mCallback(callback) { }
void unlock() { mUnlockStartTime = curClock(); mLock.unlock(); }