From 735fde8c742188d019e41faf26ff67aab6a24d25 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 21 Sep 2012 18:52:08 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages added LLThreadLocalPtr broke llmutex out into llmutex.h got primary sampling buffer under thread local storage --- indra/llcommon/llthread.h | 171 ++++------------------------------------------ 1 file changed, 15 insertions(+), 156 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index b52e70ab2e..e2de4c8b85 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -30,21 +30,21 @@ #include "llapp.h" #include "llapr.h" #include "apr_thread_cond.h" - -class LLThread; -class LLMutex; -class LLCondition; - -#if LL_WINDOWS -#define ll_thread_local __declspec(thread) -#else -#define ll_thread_local __thread -#endif +#include "lltrace.h" +#include "llthreadlocalptr.h" class LL_COMMON_API LLThread { private: + friend class LLMutex; static U32 sIDIter; +#if LL_DARWIN + // statically allocated thread local storage not supported in Darwin executable formats +#elif LL_WINDOWS + static U32 __declspec(thread) LLThread::sThreadIndex; +#elif LL_LINUX + static U32 __thread LLThread::sThreadID ; +#endif public: typedef enum e_thread_status @@ -88,6 +88,8 @@ public: U32 getID() const { return mID; } + static LLTrace::ThreadTraceData* getTraceData() { return sTraceData.get(); } + private: BOOL mPaused; @@ -96,7 +98,7 @@ private: protected: std::string mName; - LLCondition* mRunCondition; + class LLCondition* mRunCondition; apr_thread_t *mAPRThreadp; apr_pool_t *mAPRPoolp; @@ -104,6 +106,8 @@ protected: EThreadStatus mStatus; U32 mID; + static LLThreadLocalPtr sTraceData; + //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao @@ -135,149 +139,4 @@ protected: //============================================================================ -#define MUTEX_DEBUG (LL_DEBUG || LL_RELEASE_WITH_DEBUG_INFO) - -class LL_COMMON_API LLMutex -{ -public: - typedef enum - { - NO_THREAD = 0xFFFFFFFF - } e_locking_thread; - - LLMutex(apr_pool_t *apr_poolp); // NULL pool constructs a new pool for the mutex - virtual ~LLMutex(); - - void lock(); // blocks - void unlock(); - bool isLocked(); // non-blocking, but does do a lock/unlock so not free - bool isSelfLocked(); //return true if locked in a same thread - U32 lockingThread() const; //get ID of locking thread - -protected: - apr_thread_mutex_t *mAPRMutexp; - mutable U32 mCount; - mutable U32 mLockingThread; - - apr_pool_t *mAPRPoolp; - BOOL mIsLocalPool; - -#if MUTEX_DEBUG - std::map mIsLocked; -#endif -}; - -// Actually a condition/mutex pair (since each condition needs to be associated with a mutex). -class LL_COMMON_API LLCondition : public LLMutex -{ -public: - LLCondition(apr_pool_t *apr_poolp); // Defaults to global pool, could use the thread pool as well. - ~LLCondition(); - - void wait(); // blocks - void signal(); - void broadcast(); - -protected: - apr_thread_cond_t *mAPRCondp; -}; - -class LLMutexLock -{ -public: - LLMutexLock(LLMutex* mutex) - { - mMutex = mutex; - - if(mMutex) - mMutex->lock(); - } - ~LLMutexLock() - { - if(mMutex) - mMutex->unlock(); - } -private: - LLMutex* mMutex; -}; - -//============================================================================ - -void LLThread::lockData() -{ - mRunCondition->lock(); -} - -void LLThread::unlockData() -{ - mRunCondition->unlock(); -} - - -//============================================================================ - -// 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; - -private: - LLThreadSafeRefCount(const LLThreadSafeRefCount&); // not implemented - LLThreadSafeRefCount&operator=(const LLThreadSafeRefCount&); // not implemented - -protected: - virtual ~LLThreadSafeRefCount(); // use unref() - -public: - LLThreadSafeRefCount(); - - 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; -}; - -//============================================================================ - -// Simple responder for self destructing callbacks -// Pure virtual class -class LL_COMMON_API LLResponder : public LLThreadSafeRefCount -{ -protected: - virtual ~LLResponder(); -public: - virtual void completed(bool success) = 0; -}; - -//============================================================================ - #endif // LL_LLTHREAD_H -- cgit v1.2.3 From adeeabfc13c91dc99a1ea1949cd2f820c4150995 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 24 Sep 2012 18:56:01 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages moved LLThreadLocalPtr to llapr fixed various startup race conditions for LLThreadLocalPtr --- indra/llcommon/llthread.h | 1 - 1 file changed, 1 deletion(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index e2de4c8b85..e50fa7653d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -31,7 +31,6 @@ #include "llapr.h" #include "apr_thread_cond.h" #include "lltrace.h" -#include "llthreadlocalptr.h" class LL_COMMON_API LLThread { -- cgit v1.2.3 From 308ff886c3ab2aa561477921bc0d92e1bd7d399a Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 24 Sep 2012 19:01:48 -0700 Subject: fixed build moved LLThread::lockData and unlockData back to header --- indra/llcommon/llthread.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index e50fa7653d..fed111b0e4 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -136,6 +136,18 @@ protected: // mRunCondition->unlock(); }; + +void LLThread::lockData() +{ + mRunCondition->lock(); +} + +void LLThread::unlockData() +{ + mRunCondition->unlock(); +} + + //============================================================================ #endif // LL_LLTHREAD_H -- cgit v1.2.3 From 05a3203d8274a0a0999faad128f629614b8d62c5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 26 Sep 2012 17:04:57 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages fixed various issues related to unit tests and LLThreadLocalPtr initialization and teardown --- indra/llcommon/llthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index fed111b0e4..6889fab2c1 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -105,7 +105,7 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr sTraceData; + static LLThreadLocalPtr sTraceData; //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. -- cgit v1.2.3 From 07c4be092b276f0d7c14ba12872efb31c1f16764 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 26 Sep 2012 19:12:40 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages slave threads now pushing data to master thread --- indra/llcommon/llthread.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 6889fab2c1..5cd287ec39 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -87,7 +87,8 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTraceData* getTraceData() { return sTraceData.get(); } + static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); } + static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;} private: BOOL mPaused; @@ -105,7 +106,7 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr sTraceData; + static LLThreadLocalPtr sTraceData; //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. -- cgit v1.2.3 From 38354e19063478c8cda0408547ad05023b457041 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Fri, 28 Sep 2012 10:45:14 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages created separate constructor for static allocation of sampler buffer fixed start/stop/resume semantics of samplers and added sampler time interval tracking --- indra/llcommon/llthread.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 5cd287ec39..334ea2f0da 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -30,8 +30,12 @@ #include "llapp.h" #include "llapr.h" #include "apr_thread_cond.h" -#include "lltrace.h" +#include "llmutex.h" +namespace LLTrace +{ + class ThreadTrace; +} class LL_COMMON_API LLThread { private: @@ -87,8 +91,8 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTrace* getTraceData() { return sTraceData.get(); } - static void setTraceData(LLTrace::ThreadTrace* data) { sTraceData = data;} + static LLTrace::ThreadTrace* getTraceData(); + static void setTraceData(LLTrace::ThreadTrace* data); private: BOOL mPaused; -- cgit v1.2.3 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/llthread.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 334ea2f0da..82ab5f47d2 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,10 +32,6 @@ #include "apr_thread_cond.h" #include "llmutex.h" -namespace LLTrace -{ - class ThreadTrace; -} class LL_COMMON_API LLThread { private: @@ -91,9 +87,6 @@ public: U32 getID() const { return mID; } - static LLTrace::ThreadTrace* getTraceData(); - static void setTraceData(LLTrace::ThreadTrace* data); - private: BOOL mPaused; @@ -110,8 +103,6 @@ protected: EThreadStatus mStatus; U32 mID; - static LLThreadLocalPtr sTraceData; - //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao -- cgit v1.2.3 From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Nov 2012 19:46:09 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and max macros from windows.h got rest of viewer to compile against llfasttimer changes --- indra/llcommon/llthread.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 82ab5f47d2..93c752754d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,6 +32,8 @@ #include "apr_thread_cond.h" #include "llmutex.h" +LL_COMMON_API void assert_main_thread(); + class LL_COMMON_API LLThread { private: -- cgit v1.2.3 From 5d51175cd79b15cf036cd7e6bd646a1a0777eb7f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 20 Nov 2012 15:55:04 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system fixes to merge --- indra/llcommon/llthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 94b6b6d682..75222c83f9 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -42,7 +42,7 @@ private: #if LL_DARWIN // statically allocated thread local storage not supported in Darwin executable formats #elif LL_WINDOWS - static U32 __declspec(thread) LLThread::sThreadIndex; + static U32 __declspec(thread) LLThread::sThreadID; #elif LL_LINUX static U32 __thread LLThread::sThreadID ; #endif -- cgit v1.2.3 From 68967e7b2b9416ff66cb49ae755fb33d7b81d129 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 5 Dec 2012 14:22:18 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system changed thread id declaration to be local to llthread.cpp and use currentID() uniformly across platforms --- indra/llcommon/llthread.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 75222c83f9..92323f5fda 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -39,13 +39,6 @@ class LL_COMMON_API LLThread private: friend class LLMutex; static U32 sIDIter; -#if LL_DARWIN - // statically allocated thread local storage not supported in Darwin executable formats -#elif LL_WINDOWS - static U32 __declspec(thread) LLThread::sThreadID; -#elif LL_LINUX - static U32 __thread LLThread::sThreadID ; -#endif public: typedef enum e_thread_status -- cgit v1.2.3 From 6b81b8629e67d82a7620e48781ded73b6e6126ea Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 5 May 2013 17:45:35 -0700 Subject: Spring cleaning: removed unused .cpp and.h files, and cleaned up header dependencies --- indra/llcommon/llthread.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 92323f5fda..f499beca80 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -91,15 +91,15 @@ private: BOOL mPaused; // static function passed to APR thread creation routine - static void *APR_THREAD_FUNC staticRun(apr_thread_t *apr_threadp, void *datap); + static void *APR_THREAD_FUNC staticRun(struct apr_thread_t *apr_threadp, void *datap); protected: std::string mName; class LLCondition* mRunCondition; LLMutex* mDataLock; - apr_thread_t *mAPRThreadp; - apr_pool_t *mAPRPoolp; + apr_thread_t* mAPRThreadp; + apr_pool_t* mAPRPoolp; BOOL mIsLocalPool; EThreadStatus mStatus; U32 mID; @@ -107,7 +107,7 @@ protected: //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. // otherwise it will cause severe memory leaking!!! --bao - LLVolatileAPRPool *mLocalAPRFilePoolp ; + LLVolatileAPRPool* mLocalAPRFilePoolp ; void setQuitting(); -- 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/llthread.h | 81 +---------------------------------------------- 1 file changed, 1 insertion(+), 80 deletions(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 4a84a14a65..c2c6b8e7ac 100755 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,6 +32,7 @@ #include "apr_thread_cond.h" #include "boost/intrusive_ptr.hpp" #include "llmutex.h" +#include "llpointer.h" LL_COMMON_API void assert_main_thread(); @@ -148,86 +149,6 @@ void LLThread::unlockData() //============================================================================ -// 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(); - } -}; -//============================================================================ - // Simple responder for self destructing callbacks // Pure virtual class class LL_COMMON_API LLResponder : public LLThreadSafeRefCount -- 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/llthread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index c2c6b8e7ac..d7abdc4970 100755 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,7 +32,7 @@ #include "apr_thread_cond.h" #include "boost/intrusive_ptr.hpp" #include "llmutex.h" -#include "llpointer.h" +#include "llrefcount.h" LL_COMMON_API void assert_main_thread(); -- cgit v1.2.3 From d4f3fe3c5691348b72729ba57cef337c1dca0141 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 10 Dec 2013 12:50:23 -0800 Subject: SH-4653 FIX Interesting: Viewer crashes while reading chat history --- indra/llcommon/llthread.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'indra/llcommon/llthread.h') diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index ba64d20936..2f9c779e00 100755 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -36,6 +36,11 @@ LL_COMMON_API void assert_main_thread(); +namespace LLTrace +{ + class ThreadRecorder; +} + class LL_COMMON_API LLThread { private: @@ -105,6 +110,7 @@ protected: BOOL mIsLocalPool; EThreadStatus mStatus; U32 mID; + LLTrace::ThreadRecorder* mRecorder; //a local apr_pool for APRFile operations in this thread. If it exists, LLAPRFile::sAPRFilePoolp should not be used. //Note: this pool is used by APRFile ONLY, do NOT use it for any other purposes. -- cgit v1.2.3