예제 #1
0
	void lock()
		{
		mTimesAcquired++;

		preLockTimer += curClock() - mUnlockStartTime;
		mLock.lock();
		postLockTimer += curClock() - mUnlockStartTime;
		}
예제 #2
0
	~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();
		}
예제 #3
0
	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)
		{
		}
예제 #4
0
	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;
		}
예제 #5
0
ScopedPythonTracer::ScopedPythonTracer(boost::python::object inObject)
	{
	mCalledPythonObject = inObject;
	mCreationTime = curClock();
	mEnclosingScope = sCurrentTracer;
	sCurrentTracer = this;
	mTimeSpentByChildren = 0;
	}
예제 #6
0
		~Scope()
			{
			ScopedTimingAccumulator old = mAccumulator;

			mAccumulator.observe(curClock() - mT0);

			mCallback(old, mAccumulator);
			}
예제 #7
0
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;
	}
예제 #8
0
		Scope(ScopedTimingAccumulator& accumulator, const callback_type& callback) :
				mT0(curClock()),
				mAccumulator(accumulator),
				mCallback(callback)
			{
			}
예제 #9
0
	void unlock()
		{
		mUnlockStartTime = curClock();

		mLock.unlock();
		}