summaryrefslogtreecommitdiff
path: root/indra/llcommon/llfasttimer.h
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-09-05 14:04:13 -0700
committerRichard Linden <none@none>2013-09-05 14:04:13 -0700
commitcbe397ad13665c7bc993e10d8fe1e4a876253378 (patch)
tree52cd665a1138a65bd8ebfc94478c665ea40b2e25 /indra/llcommon/llfasttimer.h
parent12688c8b549d2baa33509dca60bbe14b039b17db (diff)
changed fast timer over to using macro
another attempt to move mem stat into base class
Diffstat (limited to 'indra/llcommon/llfasttimer.h')
-rwxr-xr-xindra/llcommon/llfasttimer.h32
1 files changed, 30 insertions, 2 deletions
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 7bad6134c5..e6bf544b51 100755
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -35,28 +35,56 @@
class LLMutex;
+#define LL_RECORD_BLOCK_TIME(timer_stat) const LLTrace::BlockTimer& LL_GLUE_TOKENS(block_time_recorder, __LINE__)(LLTrace::timeThisBlock(timer_stat)); (void)LL_GLUE_TOKENS(block_time_recorder, __LINE__);
+
namespace LLTrace
{
+class BlockTimer timeThisBlock(class TimeBlock& timer);
+
class BlockTimer
{
public:
- friend class TimeBlock;
typedef BlockTimer self_t;
typedef class TimeBlock DeclareTimer;
- BlockTimer(TimeBlock& timer);
~BlockTimer();
F64Seconds getElapsedTime();
private:
+ friend class TimeBlock;
+ // FIXME: this friendship exists so that each thread can instantiate a root timer,
+ // which could be a derived class with a public constructor instead, possibly
+ friend class ThreadRecorder;
+ friend BlockTimer timeThisBlock(TimeBlock&);
+ BlockTimer(TimeBlock& timer);
+#if !defined(MSC_VER) || MSC_VER < 1700
+ // Visual Studio 2010 has a bug where capturing an object returned by value
+ // into a local reference requires access to the copy constructor at the call site.
+ // This appears to be fixed in 2012.
+public:
+#endif
+ // no-copy
+ BlockTimer(const BlockTimer& other) {};
+
+private:
U64 mStartTime;
U64 mBlockStartTotalTimeCounter;
BlockTimerStackRecord mParentTimerData;
};
+// this dummy function assists in allocating a block timer with stack-based lifetime.
+// this is done by capturing the return value in a stack-allocated const reference variable.
+// (This is most easily done using the macro LL_RECORD_BLOCK_TIME)
+// Otherwise, it would be possible to store a BlockTimer on the heap, resulting in non-nested lifetimes,
+// which would break the invariants of the timing hierarchy logic
+LL_FORCE_INLINE class BlockTimer timeThisBlock(class TimeBlock& timer)
+{
+ return BlockTimer(timer);
+}
+
// stores a "named" timer instance to be reused via multiple BlockTimer stack instances
class TimeBlock
: public TraceType<TimeBlockAccumulator>,