Automated merge with bundle:c:\code\viewer-interesting+c:\users\richard\appdata\local\temp\thg._vi9rd\http__bitbucket.org_lindenlab_viewer-interesting_s1et2g.hg

meow-7.2.2
Richard Linden 2013-10-17 14:28:08 -07:00
commit 92c4677a84
5 changed files with 34 additions and 11 deletions

View File

@ -131,10 +131,10 @@ struct SortTimerByName
}
};
static BlockTimerStatHandle sRootTimer("root", NULL);
BlockTimerStatHandle& BlockTimerStatHandle::getRootTimeBlock()
{
static BlockTimerStatHandle root_timer("root", NULL);
return root_timer;
return sRootTimer;
}
void BlockTimerStatHandle::pushLog(LLSD log)
@ -333,6 +333,11 @@ std::vector<BlockTimerStatHandle*>& BlockTimerStatHandle::getChildren()
return getTreeNode().mChildren;
}
bool BlockTimerStatHandle::hasChildren()
{
return ! getTreeNode().mChildren.empty();
}
// static
void BlockTimerStatHandle::logStats()
{

View File

@ -88,7 +88,6 @@ class BlockTimerStatHandle
: public StatType<TimeBlockAccumulator>
{
public:
typedef LLInstanceTracker<StatType<TimeBlockAccumulator>, std::string> instance_tracker_t;
BlockTimerStatHandle(const char* name, const char* description = "");
TimeBlockTreeNode& getTreeNode() const;
@ -99,6 +98,7 @@ public:
typedef std::vector<BlockTimerStatHandle*>::const_iterator child_const_iter;
child_iter beginChildren();
child_iter endChildren();
bool hasChildren();
std::vector<BlockTimerStatHandle*>& getChildren();
StatType<TimeBlockAccumulator::CallCountFacet>& callCount()

View File

@ -62,16 +62,22 @@ protected:
LL_COMMON_API void assert_main_thread();
enum EInstanceTrackerAllowKeyCollisions
{
InstanceTrackerAllowKeyCollisions,
InstanceTrackerDisallowKeyCollisions
};
/// This mix-in class adds support for tracking all instances of the specified class parameter T
/// The (optional) key associates a value of type KEY with a given instance of T, for quick lookup
/// If KEY is not provided, then instances are stored in a simple set
/// @NOTE: see explicit specialization below for default KEY==void case
/// @NOTE: this class is not thread-safe unless used as read-only
template<typename T, typename KEY = void>
template<typename T, typename KEY = void, EInstanceTrackerAllowKeyCollisions ALLOW_KEY_COLLISIONS = InstanceTrackerDisallowKeyCollisions>
class LLInstanceTracker : public LLInstanceTrackerBase
{
typedef LLInstanceTracker<T, KEY> self_t;
typedef typename std::map<KEY, T*> InstanceMap;
typedef typename std::multimap<KEY, T*> InstanceMap;
struct StaticData: public StaticBase
{
InstanceMap sMap;
@ -208,7 +214,18 @@ private:
void add_(KEY key)
{
mInstanceKey = key;
getMap_()[key] = static_cast<T*>(this);
InstanceMap& map = getMap_();
InstanceMap::iterator insertion_point_it = map.lower_bound(key);
if (ALLOW_KEY_COLLISIONS == InstanceTrackerDisallowKeyCollisions
&& insertion_point_it != map.end()
&& insertion_point_it->first == key)
{
LL_ERRS() << "Key " << key << " already exists in instance map for " << typeid(T).name() << LL_ENDL;
}
else
{
map.insert(insertion_point_it, std::make_pair(key, static_cast<T*>(this)));
}
}
void remove_()
{
@ -225,8 +242,8 @@ private:
/// explicit specialization for default case where KEY is void
/// use a simple std::set<T*>
template<typename T>
class LLInstanceTracker<T, void> : public LLInstanceTrackerBase
template<typename T, EInstanceTrackerAllowKeyCollisions ALLOW_KEY_COLLISIONS>
class LLInstanceTracker<T, void, ALLOW_KEY_COLLISIONS> : public LLInstanceTrackerBase
{
typedef LLInstanceTracker<T, void> self_t;
typedef typename std::set<T*> InstanceSet;

View File

@ -69,11 +69,12 @@ protected:
template<typename ACCUMULATOR>
class StatType
: public StatBase,
public LLInstanceTracker<StatType<ACCUMULATOR>, std::string>
public LLInstanceTracker<StatType<ACCUMULATOR>, std::string, InstanceTrackerAllowKeyCollisions>
{
public:
typedef LLInstanceTracker<StatType<ACCUMULATOR>, std::string, InstanceTrackerAllowKeyCollisions> instance_tracker_t;
StatType(const char* name, const char* description)
: LLInstanceTracker<StatType<ACCUMULATOR>, std::string>(name),
: instance_tracker_t(name),
StatBase(name, description),
mAccumulatorIndex(AccumulatorBuffer<ACCUMULATOR>::getDefaultBuffer()->reserveSlot())
{}

View File

@ -81,7 +81,7 @@ void ThreadRecorder::init()
BlockTimerStatHandle::getRootTimeBlock().getCurrentAccumulator().mActiveCount = 1;
claim_alloc(gTraceMemStat, this);
claim_alloc(gTraceMemStat, sizeof(BlockTimer));
claim_alloc(gTraceMemStat, mRootTimer);
claim_alloc(gTraceMemStat, sizeof(TimeBlockTreeNode) * mNumTimeBlockTreeNodes);
}