diff options
Diffstat (limited to 'indra/llcommon/llinstancetracker.h')
-rw-r--r-- | indra/llcommon/llinstancetracker.h | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h index f45144085b..03418e9bad 100644 --- a/indra/llcommon/llinstancetracker.h +++ b/indra/llcommon/llinstancetracker.h @@ -52,7 +52,7 @@ namespace LLInstanceTrackerPrivate struct StaticBase { // We need to be able to lock static data while manipulating it. - std::mutex mMutex; + LL_PROFILE_MUTEX_NAMED(std::mutex, mMutex, "InstanceTracker Data"); }; void logerrs(const char* cls, const std::string&, const std::string&, const std::string&); @@ -103,7 +103,8 @@ public: static size_t instanceCount() { - return LockStatic()->mMap.size(); + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); + return lock->mMap.size(); } // snapshot of std::pair<const KEY, std::shared_ptr<SUBCLASS>> pairs, for @@ -222,7 +223,7 @@ public: static ptr_t getInstance(const KEY& k) { - LockStatic lock; + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); const InstanceMap& map(lock->mMap); typename InstanceMap::const_iterator found = map.find(k); return (found == map.end()) ? NULL : found->second; @@ -238,19 +239,19 @@ protected: ptr_t ptr(static_cast<T*>(this), [](T*){}); // save corresponding weak_ptr for future reference mSelf = ptr; - LockStatic lock; + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); add_(lock, key, ptr); } public: virtual ~LLInstanceTracker() { - LockStatic lock; + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); remove_(lock); } protected: virtual void setKey(KEY key) { - LockStatic lock; + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); // Even though the shared_ptr we store in our map has a no-op deleter // for T itself, letting the use count decrement to 0 will still // delete the use-count object. Capture the shared_ptr we just removed @@ -392,7 +393,8 @@ public: static size_t instanceCount() { - return LockStatic()->mSet.size(); + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); + return lock->mSet.size(); } // snapshot of std::shared_ptr<SUBCLASS> pointers @@ -511,14 +513,16 @@ protected: // save corresponding weak_ptr for future reference mSelf = ptr; // Also store it in our class-static set to track this instance. - LockStatic()->mSet.emplace(ptr); + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); + lock->mSet.emplace(ptr); } public: virtual ~LLInstanceTracker() { // convert weak_ptr to shared_ptr because that's what we store in our // InstanceSet - LockStatic()->mSet.erase(mSelf.lock()); + LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex); + lock->mSet.erase(mSelf.lock()); } protected: LLInstanceTracker(const LLInstanceTracker& other): |