From 14b1b0b2bb6bac5bc688cc4d14c33f1b680dd3b4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 1 Oct 2012 19:39:04 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages cleaned up API samplers are now value types with copy-on-write buffers under the hood removed coupling with LLThread --- indra/llcommon/llpointer.h | 83 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 88c09c8dca..0fee4f0990 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -97,24 +97,13 @@ public: LLPointer& operator =(Type* ptr) { - if( mPointer != ptr ) - { - unref(); - mPointer = ptr; - ref(); - } - + assign(ptr); return *this; } LLPointer& operator =(const LLPointer& ptr) { - if( mPointer != ptr.mPointer ) - { - unref(); - mPointer = ptr.mPointer; - ref(); - } + assign(ptr); return *this; } @@ -122,12 +111,7 @@ public: template LLPointer& operator =(const LLPointer& ptr) { - if( mPointer != ptr.get() ) - { - unref(); - mPointer = ptr.get(); - ref(); - } + assign(ptr.get()); return *this; } @@ -144,6 +128,16 @@ protected: void ref(); void unref(); #else + + void assign(const LLPointer& ptr) + { + if( mPointer != ptr.mPointer ) + { + unref(); + mPointer = ptr.mPointer; + ref(); + } + } void ref() { if (mPointer) @@ -156,9 +150,9 @@ protected: { if (mPointer) { - Type *tempp = mPointer; + Type *temp = mPointer; mPointer = NULL; - tempp->unref(); + temp->unref(); if (mPointer != NULL) { llwarns << "Unreference did assignment to non-NULL because of destructor" << llendl; @@ -171,4 +165,51 @@ protected: Type* mPointer; }; +template +class LLCopyOnWritePointer : public LLPointer +{ +public: + typedef LLPointer ref_pointer_t; + typedef LLCopyOnWritePointer self_t; + + LLCopyOnWritePointer() + { + } + + LLCopyOnWritePointer(Type* ptr) + : LLPointer(ptr) + { + } + + Type* write() + { + makeUnique(); + return mPointer; + } + + void makeUnique() + { + if (mPointer && mPointer->getNumRefs() > 1) + { + ref_pointer_t::assign(new Type(*mPointer)); + } + } + + using ref_pointer_t::operator BOOL; + using ref_pointer_t::operator bool; + using ref_pointer_t::operator!; + + using ref_pointer_t::operator !=; + using ref_pointer_t::operator ==; + using LLPointer::operator =; + + using LLPointer::operator <; + using LLPointer::operator >; + + + operator const Type*() const { return mPointer; } + const Type* operator->() const { return mPointer; } + +}; + #endif -- cgit v1.2.3 From 041dfccd1ea5b59c1b3c4e37e9a5495cad342c8f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 12 Oct 2012 20:17:52 -0700 Subject: SH-3405 WIP convert existing stats to lltrace system default to double precision now fixed unit conversion logic for LLUnit renamed LLTrace::Rate to LLTrace::Count and got rid of the old count as it was confusing some const correctness changes --- indra/llcommon/llpointer.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 0fee4f0990..6a3bbeb768 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -207,7 +207,9 @@ public: using LLPointer::operator >; + operator Type*() { return mPointer; } operator const Type*() const { return mPointer; } + Type* operator->() { return mPointer; } const Type* operator->() const { return mPointer; } }; -- cgit v1.2.3 From 60800dacdd7e9b66ed654af471f2b9e9680cd981 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 6 Dec 2012 00:37:15 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixed gcc compile error made LLCopyOnWritePointer contain an LLPointer, not derive from it added type trait to control periodicrecording mean value type --- indra/llcommon/llpointer.h | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 6a3bbeb768..f03551045e 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -166,52 +166,52 @@ protected: }; template -class LLCopyOnWritePointer : public LLPointer +class LLCopyOnWritePointer { public: - typedef LLPointer ref_pointer_t; typedef LLCopyOnWritePointer self_t; LLCopyOnWritePointer() - { - } + {} LLCopyOnWritePointer(Type* ptr) - : LLPointer(ptr) - { - } + : mPointer(ptr) + {} + + LLCopyOnWritePointer(LLPointer& ptr) + : mPointer(ptr) + {} Type* write() { makeUnique(); - return mPointer; + return mPointer.get(); } void makeUnique() { - if (mPointer && mPointer->getNumRefs() > 1) + if (mPointer.notNull() && mPointer.get()->getNumRefs() > 1) { - ref_pointer_t::assign(new Type(*mPointer)); + mPointer = new Type(*mPointer.get()); } } - using ref_pointer_t::operator BOOL; - using ref_pointer_t::operator bool; - using ref_pointer_t::operator!; - - using ref_pointer_t::operator !=; - using ref_pointer_t::operator ==; - using LLPointer::operator =; + operator BOOL() const { return (BOOL)mPointer; } + operator bool() const { return (bool)mPointer; } + bool operator!() const { return !mPointer; } + bool isNull() const { return mPointer.isNull(); } + bool notNull() const { return mPointer.notNull(); } - using LLPointer::operator <; - using LLPointer::operator >; - - - operator Type*() { return mPointer; } - operator const Type*() const { return mPointer; } - Type* operator->() { return mPointer; } - const Type* operator->() const { return mPointer; } + bool operator !=(Type* ptr) const { return (mPointer.get() != ptr); } + bool operator ==(Type* ptr) const { return (mPointer.get() == ptr); } + bool operator ==(const LLCopyOnWritePointer& ptr) const { return (mPointer == ptr.mPointer); } + bool operator < (const LLCopyOnWritePointer& ptr) const { return (mPointer < ptr.mPointer); } + bool operator > (const LLCopyOnWritePointer& ptr) const { return (mPointer > ptr.mPointer); } + operator const Type*() const { return mPointer.get(); } + const Type* operator->() const { return mPointer.get(); } +protected: + LLPointer mPointer; }; #endif -- cgit v1.2.3 From ab5106535758393e02b075d1e404e4e1fcf81abf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 20 May 2013 19:27:50 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics removed extra dereference for copy on write pointer moved copyonwrite mechanism to RecordingBuffers from individual buffer fixed logic that was leaving scene unfrozen when camera moved during metrics gathering --- indra/llcommon/llpointer.h | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index f03551045e..b9a9bf1ef0 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -166,7 +166,7 @@ protected: }; template -class LLCopyOnWritePointer +class LLCopyOnWritePointer : public LLPointer { public: typedef LLCopyOnWritePointer self_t; @@ -175,43 +175,40 @@ public: {} LLCopyOnWritePointer(Type* ptr) - : mPointer(ptr) + : LLPointer(ptr) {} LLCopyOnWritePointer(LLPointer& ptr) - : mPointer(ptr) + : LLPointer(ptr) {} Type* write() { makeUnique(); - return mPointer.get(); + return mPointer; } void makeUnique() { - if (mPointer.notNull() && mPointer.get()->getNumRefs() > 1) + if (notNull() && mPointer->getNumRefs() > 1) { - mPointer = new Type(*mPointer.get()); + *(LLPointer*)(this) = new Type(*mPointer); } } + /*operator BOOL() const { return (mPointer != NULL); } + operator bool() const { return (mPointer != NULL); } + bool operator!() const { return (mPointer == NULL); } + bool isNull() const { return (mPointer == NULL); } + bool notNull() const { return (mPointer != NULL); } - operator BOOL() const { return (BOOL)mPointer; } - operator bool() const { return (bool)mPointer; } - bool operator!() const { return !mPointer; } - bool isNull() const { return mPointer.isNull(); } - bool notNull() const { return mPointer.notNull(); } - - bool operator !=(Type* ptr) const { return (mPointer.get() != ptr); } - bool operator ==(Type* ptr) const { return (mPointer.get() == ptr); } + bool operator !=(Type* ptr) const { return (mPointer != ptr); } + bool operator ==(Type* ptr) const { return (mPointer == ptr); } bool operator ==(const LLCopyOnWritePointer& ptr) const { return (mPointer == ptr.mPointer); } bool operator < (const LLCopyOnWritePointer& ptr) const { return (mPointer < ptr.mPointer); } bool operator > (const LLCopyOnWritePointer& ptr) const { return (mPointer > ptr.mPointer); } - operator const Type*() const { return mPointer.get(); } - const Type* operator->() const { return mPointer.get(); } -protected: - LLPointer mPointer; + operator const Type*() const { return mPointer; } + const Type* operator->() const { return mPointer; }*/ }; #endif -- cgit v1.2.3 From 7aeac00e444ebf3fdc73bdc4be3c47bb9ae65e43 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 21 May 2013 10:20:30 -0700 Subject: BUIDLFIX: trying to make gcc happy --- indra/llcommon/llpointer.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index b9a9bf1ef0..3273a85af1 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -175,11 +175,11 @@ public: {} LLCopyOnWritePointer(Type* ptr) - : LLPointer(ptr) + : LLPointer(ptr) {} LLCopyOnWritePointer(LLPointer& ptr) - : LLPointer(ptr) + : LLPointer(ptr) {} Type* write() @@ -190,25 +190,11 @@ public: void makeUnique() { - if (notNull() && mPointer->getNumRefs() > 1) + if (LLPointer::notNull() && mPointer->getNumRefs() > 1) { - *(LLPointer*)(this) = new Type(*mPointer); + *(LLPointer*)(this) = new Type(*mPointer); } } - /*operator BOOL() const { return (mPointer != NULL); } - operator bool() const { return (mPointer != NULL); } - bool operator!() const { return (mPointer == NULL); } - bool isNull() const { return (mPointer == NULL); } - bool notNull() const { return (mPointer != NULL); } - - bool operator !=(Type* ptr) const { return (mPointer != ptr); } - bool operator ==(Type* ptr) const { return (mPointer == ptr); } - bool operator ==(const LLCopyOnWritePointer& ptr) const { return (mPointer == ptr.mPointer); } - bool operator < (const LLCopyOnWritePointer& ptr) const { return (mPointer < ptr.mPointer); } - bool operator > (const LLCopyOnWritePointer& ptr) const { return (mPointer > ptr.mPointer); } - - operator const Type*() const { return mPointer; } - const Type* operator->() const { return mPointer; }*/ }; #endif -- cgit v1.2.3 From 269fb97eba380baf5674178294bf86fb01cd712c Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 21 May 2013 10:28:21 -0700 Subject: BUILDFIX: gcc fixes --- indra/llcommon/llpointer.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 3273a85af1..c83e55577d 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -170,7 +170,8 @@ class LLCopyOnWritePointer : public LLPointer { public: typedef LLCopyOnWritePointer self_t; - + typedef LLPointer pointer_t; + LLCopyOnWritePointer() {} @@ -185,14 +186,14 @@ public: Type* write() { makeUnique(); - return mPointer; + return pointer_t::mPointer; } void makeUnique() { - if (LLPointer::notNull() && mPointer->getNumRefs() > 1) + if (pointer_t::notNull() && pointer_t::mPointer->getNumRefs() > 1) { - *(LLPointer*)(this) = new Type(*mPointer); + *(pointer_t*)(this) = new Type(*pointer_t::mPointer); } } }; -- cgit v1.2.3 From 074c1f1de45f60059c97cf9cfd0bbb9fddbb52c4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 29 May 2013 17:02:27 -0700 Subject: SH-3931 WIP Interesting: Add graphs to visualize scene load metrics made LLCopyOnWritePointer enforce write access through write() again disabled some error checking on release for download builds --- indra/llcommon/llpointer.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index c83e55577d..e640ffd595 100644 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -196,6 +196,9 @@ public: *(pointer_t*)(this) = new Type(*pointer_t::mPointer); } } + + const Type* operator->() const { return pointer_t::mPointer; } + const Type& operator*() const { return *pointer_t::mPointer; } }; #endif -- cgit v1.2.3 From 60b625588faec2472597dae50331b2ce95ce40a2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 5 Jun 2013 19:57:07 -0700 Subject: BUILDFIX: build fixes for mac --- indra/llcommon/llpointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index e640ffd595..6a0a8fcb0d 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -193,7 +193,7 @@ public: { if (pointer_t::notNull() && pointer_t::mPointer->getNumRefs() > 1) { - *(pointer_t*)(this) = new Type(*pointer_t::mPointer); + *(pointer_t* )(this) = new Type(*pointer_t::mPointer); } } -- cgit v1.2.3 From ffa7123bb5187e1da491a8f475d696053d9c9ee4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Jun 2013 20:45:20 -0700 Subject: SH-4299 FIX Interesting: High fps shown temporarily off scale in statistics console added ability to force uniqueness of LLCopyOnWritePointer converted more variables to units added convenience function for unit constants --- indra/llcommon/llpointer.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 6a0a8fcb0d..c827996db1 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -173,15 +173,23 @@ public: typedef LLPointer pointer_t; LLCopyOnWritePointer() + : mStayUnique(false) {} LLCopyOnWritePointer(Type* ptr) - : LLPointer(ptr) + : LLPointer(ptr), + mStayUnique(false) {} LLCopyOnWritePointer(LLPointer& ptr) - : LLPointer(ptr) - {} + : LLPointer(ptr), + mStayUnique(false) + { + if (ptr.mForceUnique) + { + makeUnique(); + } + } Type* write() { @@ -199,6 +207,10 @@ public: const Type* operator->() const { return pointer_t::mPointer; } const Type& operator*() const { return *pointer_t::mPointer; } + + void setStayUnique(bool stay) { makeUnique(); mStayUnique = stay; } +private: + bool mStayUnique; }; #endif -- cgit v1.2.3 From 075a7bcc980b0ca0d2888d344b6afa8ab5b52d85 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 18 Jul 2013 15:09:45 -0700 Subject: SH-4297 WIP interesting: viewer-interesting starts loading cached scene late dependency cleanup - removed a lot of unecessary includes --- indra/llcommon/llpointer.h | 79 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index c827996db1..9a0726c338 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -27,6 +27,7 @@ #define LLPOINTER_H #include "llerror.h" // *TODO: consider eliminating this +#include "llmutex.h" //---------------------------------------------------------------------------- // RefCount objects should generally only be accessed by way of LLPointer<>'s @@ -213,4 +214,82 @@ private: bool mStayUnique; }; +//============================================================================ + +// see llmemory.h for LLPointer<> definition + +class LL_COMMON_API LLThreadSafeRefCount +{ +public: + static void initThreadSafeRefCount(); // creates sMutex + static void cleanupThreadSafeRefCount(); // destroys sMutex + +private: + static LLMutex* sMutex; + +protected: + virtual ~LLThreadSafeRefCount(); // use unref() + +public: + LLThreadSafeRefCount(); + LLThreadSafeRefCount(const LLThreadSafeRefCount&); + LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) + { + if (sMutex) + { + sMutex->lock(); + } + mRef = 0; + if (sMutex) + { + sMutex->unlock(); + } + return *this; + } + + void ref() + { + if (sMutex) sMutex->lock(); + mRef++; + if (sMutex) sMutex->unlock(); + } + + S32 unref() + { + llassert(mRef >= 1); + if (sMutex) sMutex->lock(); + S32 res = --mRef; + if (sMutex) sMutex->unlock(); + if (0 == res) + { + delete this; + return 0; + } + return res; + } + S32 getNumRefs() const + { + return mRef; + } + +private: + S32 mRef; +}; + +/** + * intrusive pointer support for LLThreadSafeRefCount + * this allows you to use boost::intrusive_ptr with any LLThreadSafeRefCount-derived type + */ +namespace boost +{ + inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p) + { + p->ref(); + } + + inline void intrusive_ptr_release(LLThreadSafeRefCount* p) + { + p->unref(); + } +}; #endif -- cgit v1.2.3 From e5b51c7f6cfd1ecf374fe8b705f94968a402c573 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 22 Jul 2013 11:01:52 -0700 Subject: BUIDLFIX: moved LLThreadSafeRefCount to proper file --- indra/llcommon/llpointer.h | 78 ---------------------------------------------- 1 file changed, 78 deletions(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index 9a0726c338..e09741b0ec 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -214,82 +214,4 @@ private: bool mStayUnique; }; -//============================================================================ - -// see llmemory.h for LLPointer<> definition - -class LL_COMMON_API LLThreadSafeRefCount -{ -public: - static void initThreadSafeRefCount(); // creates sMutex - static void cleanupThreadSafeRefCount(); // destroys sMutex - -private: - static LLMutex* sMutex; - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - LLThreadSafeRefCount(const LLThreadSafeRefCount&); - LLThreadSafeRefCount& operator=(const LLThreadSafeRefCount& ref) - { - if (sMutex) - { - sMutex->lock(); - } - mRef = 0; - if (sMutex) - { - sMutex->unlock(); - } - return *this; - } - - void ref() - { - if (sMutex) sMutex->lock(); - mRef++; - if (sMutex) sMutex->unlock(); - } - - S32 unref() - { - llassert(mRef >= 1); - if (sMutex) sMutex->lock(); - S32 res = --mRef; - if (sMutex) sMutex->unlock(); - if (0 == res) - { - delete this; - return 0; - } - return res; - } - S32 getNumRefs() const - { - return mRef; - } - -private: - S32 mRef; -}; - -/** - * intrusive pointer support for LLThreadSafeRefCount - * this allows you to use boost::intrusive_ptr with any LLThreadSafeRefCount-derived type - */ -namespace boost -{ - inline void intrusive_ptr_add_ref(LLThreadSafeRefCount* p) - { - p->ref(); - } - - inline void intrusive_ptr_release(LLThreadSafeRefCount* p) - { - p->unref(); - } -}; #endif -- cgit v1.2.3 From e340009fc59d59e59b2e8d903a884acb76b178eb Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 9 Aug 2013 17:11:19 -0700 Subject: second phase summer cleaning replace llinfos, lldebugs, etc with new LL_INFOS(), LL_DEBUGS(), etc. --- indra/llcommon/llpointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llpointer.h') diff --git a/indra/llcommon/llpointer.h b/indra/llcommon/llpointer.h index e09741b0ec..c9ebc70d19 100755 --- a/indra/llcommon/llpointer.h +++ b/indra/llcommon/llpointer.h @@ -156,7 +156,7 @@ protected: temp->unref(); if (mPointer != NULL) { - llwarns << "Unreference did assignment to non-NULL because of destructor" << llendl; + LL_WARNS() << "Unreference did assignment to non-NULL because of destructor" << LL_ENDL; unref(); } } -- cgit v1.2.3