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 3232a0e219..92b26354a1 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&); @@ -101,7 +101,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 @@ -236,7 +237,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; @@ -252,19 +253,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 @@ -376,7 +377,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 @@ -488,14 +490,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): |