summaryrefslogtreecommitdiff
path: root/indra/llcommon/lltrace.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2012-09-26 17:04:57 -0700
committerRichard Linden <none@none>2012-09-26 17:04:57 -0700
commit05a3203d8274a0a0999faad128f629614b8d62c5 (patch)
tree7d2e980d711576b9e05f2a36084d8712a3eba330 /indra/llcommon/lltrace.h
parent308ff886c3ab2aa561477921bc0d92e1bd7d399a (diff)
SH-3275 WIP Run viewer metrics for object update messages
fixed various issues related to unit tests and LLThreadLocalPtr initialization and teardown
Diffstat (limited to 'indra/llcommon/lltrace.h')
-rw-r--r--indra/llcommon/lltrace.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h
index 3af05d67f9..e4bec0a644 100644
--- a/indra/llcommon/lltrace.h
+++ b/indra/llcommon/lltrace.h
@@ -44,8 +44,7 @@ namespace LLTrace
void init();
void cleanup();
- extern class MasterThreadTrace *gMasterThreadTrace;
- extern LLThreadLocalPtr<class ThreadTraceData> gCurThreadTrace;
+ class MasterThreadTrace& getMasterThreadTrace();
// one per thread per type
template<typename ACCUMULATOR>
@@ -59,8 +58,8 @@ namespace LLTrace
: mStorageSize(64),
mNextStorageSlot(0),
mStorage(new ACCUMULATOR[DEFAULT_ACCUMULATOR_BUFFER_SIZE])
- {
- }
+ {}
+
public:
AccumulatorBuffer(const AccumulatorBuffer& other = getDefaultBuffer())
@@ -69,6 +68,15 @@ namespace LLTrace
mNextStorageSlot(other.mNextStorageSlot)
{}
+ ~AccumulatorBuffer()
+ {
+ if (sPrimaryStorage == mStorage)
+ {
+ //TODO pick another primary?
+ sPrimaryStorage = NULL;
+ }
+ }
+
LL_FORCE_INLINE ACCUMULATOR& operator[](size_t index)
{
return mStorage[index];
@@ -353,7 +361,8 @@ namespace LLTrace
mTimers(other.mTimers)
{}
- ~Sampler() {}
+ ~Sampler()
+ {}
void makePrimary()
{
@@ -453,21 +462,21 @@ namespace LLTrace
void addSlaveThread(class SlaveThreadTrace* child);
void removeSlaveThread(class SlaveThreadTrace* child);
- // call this periodically to gather stats data from worker threads
- void pullFromWorkerThreads();
+ // call this periodically to gather stats data from slave threads
+ void pullFromSlaveThreads();
private:
- struct WorkerThreadTraceProxy
+ struct SlaveThreadTraceProxy
{
- WorkerThreadTraceProxy(class SlaveThreadTrace* trace)
- : mWorkerTrace(trace)
+ SlaveThreadTraceProxy(class SlaveThreadTrace* trace)
+ : mSlaveTrace(trace)
{}
- class SlaveThreadTrace* mWorkerTrace;
+ class SlaveThreadTrace* mSlaveTrace;
Sampler mSamplerStorage;
};
- typedef std::list<WorkerThreadTraceProxy> worker_thread_trace_list_t;
+ typedef std::list<SlaveThreadTraceProxy> slave_thread_trace_list_t;
- worker_thread_trace_list_t mSlaveThreadTraces;
+ slave_thread_trace_list_t mSlaveThreadTraces;
LLMutex mSlaveListMutex;
};
@@ -475,17 +484,16 @@ namespace LLTrace
{
public:
explicit
- SlaveThreadTrace(MasterThreadTrace& master_trace = *gMasterThreadTrace)
- : mMaster(master_trace),
- ThreadTraceData(master_trace),
+ SlaveThreadTrace()
+ : ThreadTraceData(getMasterThreadTrace()),
mSharedData(mPrimarySampler)
{
- master_trace.addSlaveThread(this);
+ getMasterThreadTrace().addSlaveThread(this);
}
~SlaveThreadTrace()
{
- mMaster.removeSlaveThread(this);
+ getMasterThreadTrace().removeSlaveThread(this);
}
// call this periodically to gather stats data for master thread to consume
@@ -494,7 +502,7 @@ namespace LLTrace
mSharedData.copyFrom(mPrimarySampler);
}
- MasterThreadTrace& mMaster;
+ MasterThreadTrace* mMaster;
// this data is accessed by other threads, so give it a 64 byte alignment
// to avoid false sharing on most x86 processors
@@ -529,7 +537,6 @@ namespace LLTrace
SharedData mSharedData;
};
-
class TimeInterval
{
public: