diff options
| author | Richard Linden <none@none> | 2013-05-30 19:00:08 -0700 | 
|---|---|---|
| committer | Richard Linden <none@none> | 2013-05-30 19:00:08 -0700 | 
| commit | ae6763f7fcfbe52ea1b04c25603ac2305beafb9d (patch) | |
| tree | fffe67ae8ce06af0e2c4ef0f874d140623efaa66 /indra/llcommon/lltrace.h | |
| parent | ee0087709afe05a9fe38e3da743421faead9e02f (diff) | |
| parent | ae355188327515d53b9c15c27ed576829fce3668 (diff) | |
Automated merge with bundle:c:\code\viewer-interesting+c:\users\richard\appdata\local\temp\thg.sszl0v\ssh__richard@hg.lindenlab.com_richard_viewer-interesting_kkjl59.hg
Diffstat (limited to 'indra/llcommon/lltrace.h')
| -rw-r--r-- | indra/llcommon/lltrace.h | 21 | 
1 files changed, 12 insertions, 9 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index e950a119d3..00bab536ff 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -35,6 +35,7 @@  #include "llunit.h"  #include "llapr.h"  #include "llthreadlocalstorage.h" +#include "lltimer.h"  #include <list> @@ -75,7 +76,6 @@ void set_thread_recorder(class ThreadRecorder*);  class MasterThreadRecorder& getUIThreadRecorder(); -// one per thread per type  template<typename ACCUMULATOR>  class AccumulatorBuffer : public LLRefCount  { @@ -104,9 +104,9 @@ public:  	~AccumulatorBuffer()  	{ -		if (LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance() == mStorage) +		if (isPrimary())  		{ -			LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(getDefaultBuffer()->mStorage); +			LLThreadLocalSingletonPointer<ACCUMULATOR>::setInstance(NULL);  		}  		delete[] mStorage;  	} @@ -169,7 +169,8 @@ public:  	LL_FORCE_INLINE static ACCUMULATOR* getPrimaryStorage()   	{  -		return LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance();  +		ACCUMULATOR* accumulator = LLThreadLocalSingletonPointer<ACCUMULATOR>::getInstance(); +		return accumulator ? accumulator : sDefaultBuffer->mStorage;  	}  	// NOTE: this is not thread-safe.  We assume that slots are reserved in the main thread before any child threads are spawned @@ -222,25 +223,27 @@ public:  	static self_t* getDefaultBuffer()  	{ -		// this buffer is allowed to leak so that trace calls from global destructors have somewhere to put their data -		// so as not to trigger an access violation -		static self_t* sBuffer = new AccumulatorBuffer(StaticAllocationMarker());  		static bool sInitialized = false;  		if (!sInitialized)  		{ -			sBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE); +			// this buffer is allowed to leak so that trace calls from global destructors have somewhere to put their data +			// so as not to trigger an access violation +			sDefaultBuffer = new AccumulatorBuffer(StaticAllocationMarker());  			sInitialized = true; +			sDefaultBuffer->resize(DEFAULT_ACCUMULATOR_BUFFER_SIZE);  		} -		return sBuffer; +		return sDefaultBuffer;  	}  private:  	ACCUMULATOR*	mStorage;  	size_t			mStorageSize;  	static size_t	sNextStorageSlot; +	static self_t*	sDefaultBuffer;  };  template<typename ACCUMULATOR> size_t AccumulatorBuffer<ACCUMULATOR>::sNextStorageSlot = 0; +template<typename ACCUMULATOR> AccumulatorBuffer<ACCUMULATOR>* AccumulatorBuffer<ACCUMULATOR>::sDefaultBuffer = NULL;  template<typename ACCUMULATOR>  class TraceType   | 
