summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/lleventapi.h5
-rw-r--r--indra/llcommon/lleventtimer.h3
-rw-r--r--indra/llcommon/llfasttimer.h5
-rw-r--r--indra/llcommon/llinstancetracker.cpp14
-rw-r--r--indra/llcommon/llinstancetracker.h46
-rw-r--r--indra/llcommon/llleap.h3
6 files changed, 51 insertions, 25 deletions
diff --git a/indra/llcommon/lleventapi.h b/indra/llcommon/lleventapi.h
index 1a37d780b6..10c7e7a23f 100644
--- a/indra/llcommon/lleventapi.h
+++ b/indra/llcommon/lleventapi.h
@@ -41,12 +41,13 @@
* Deriving from LLInstanceTracker lets us enumerate instances.
*/
class LL_COMMON_API LLEventAPI: public LLDispatchListener,
- public LLInstanceTracker<LLEventAPI, std::string>
+ public INSTANCE_TRACKER_KEYED(LLEventAPI, std::string)
{
typedef LLDispatchListener lbase;
- typedef LLInstanceTracker<LLEventAPI, std::string> ibase;
+ typedef INSTANCE_TRACKER_KEYED(LLEventAPI, std::string) ibase;
public:
+
/**
* @param name LLEventPump name on which this LLEventAPI will listen. This
* also serves as the LLInstanceTracker instance key.
diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h
index 7f42623d01..e55f851758 100644
--- a/indra/llcommon/lleventtimer.h
+++ b/indra/llcommon/lleventtimer.h
@@ -33,9 +33,10 @@
#include "lltimer.h"
// class for scheduling a function to be called at a given frequency (approximate, inprecise)
-class LL_COMMON_API LLEventTimer : public LLInstanceTracker<LLEventTimer>
+class LL_COMMON_API LLEventTimer : public INSTANCE_TRACKER(LLEventTimer)
{
public:
+
LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds
LLEventTimer(const LLDate& time);
virtual ~LLEventTimer();
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index e42e549df5..440d42ab5a 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -63,7 +63,7 @@ public:
// stores a "named" timer instance to be reused via multiple LLFastTimer stack instances
class LL_COMMON_API NamedTimer
- : public LLInstanceTracker<NamedTimer>
+ : public LLInstanceTracker<NamedTimer, InstanceTrackType_NamedTimer >
{
friend class DeclareTimer;
public:
@@ -137,10 +137,11 @@ public:
// used to statically declare a new named timer
class LL_COMMON_API DeclareTimer
- : public LLInstanceTracker<DeclareTimer>
+ : public LLInstanceTracker< DeclareTimer, InstanceTrackType_DeclareTimer >
{
friend class LLFastTimer;
public:
+
DeclareTimer(const std::string& name, bool open);
DeclareTimer(const std::string& name);
diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp
index 5dc3ea5d7b..0804be358f 100644
--- a/indra/llcommon/llinstancetracker.cpp
+++ b/indra/llcommon/llinstancetracker.cpp
@@ -32,18 +32,14 @@
// external library headers
// other Linden headers
-//static
-void * & LLInstanceTrackerBase::getInstances(std::type_info const & info)
-{
- typedef std::map<std::string, void *> InstancesMap;
- static InstancesMap instances;
+static void* sInstanceTrackerData[ kInstanceTrackTypeCount ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+void * & LLInstanceTrackerBase::getInstances(InstanceTrackType t)
+{
// std::map::insert() is just what we want here. You attempt to insert a
// (key, value) pair. If the specified key doesn't yet exist, it inserts
// the pair and returns a std::pair of (iterator, true). If the specified
// key DOES exist, insert() simply returns (iterator, false). One lookup
// handles both cases.
- return instances.insert(InstancesMap::value_type(info.name(),
- InstancesMap::mapped_type()))
- .first->second;
-}
+ return sInstanceTrackerData[t];
+} \ No newline at end of file
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h
index 403df08990..70bccde992 100644
--- a/indra/llcommon/llinstancetracker.h
+++ b/indra/llcommon/llinstancetracker.h
@@ -38,6 +38,31 @@
#include <boost/iterator/transform_iterator.hpp>
#include <boost/iterator/indirect_iterator.hpp>
+enum InstanceTrackType
+{
+ InstanceTrackType_LLEventAPI,
+ InstanceTrackType_LLEventTimer,
+ InstanceTrackType_NamedTimer,
+ InstanceTrackType_DeclareTimer,
+ InstanceTrackType_LLLeap,
+ InstanceTrackType_LLGLNamePool,
+ InstanceTrackType_LLConsole,
+ InstanceTrackType_LLFloater,
+ InstanceTrackType_LLFloaterWebContent,
+ InstanceTrackType_LLLayoutStack,
+ InstanceTrackType_LLNotificationContext,
+ InstanceTrackType_LLWindow,
+ InstanceTrackType_LLControlGroup,
+ InstanceTrackType_LLControlCache,
+ InstanceTrackType_LLMediaCtrl,
+ InstanceTrackType_LLNameListCtrl,
+ InstanceTrackType_LLToast,
+ kInstanceTrackTypeCount
+};
+
+#define INSTANCE_TRACKER(T) LLInstanceTracker< T, InstanceTrackType_##T >
+#define INSTANCE_TRACKER_KEYED(T,K) LLInstanceTracker< T, InstanceTrackType_##T, K >
+
/**
* Base class manages "class-static" data that must actually have singleton
* semantics: one instance per process, rather than one instance per module as
@@ -47,14 +72,15 @@ class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable
{
protected:
/// Get a process-unique void* pointer slot for the specified type_info
- static void * & getInstances(std::type_info const & info);
+ //static void * & getInstances(std::type_info const & info);
+ static void * & getInstances(InstanceTrackType t);
/// Find or create a STATICDATA instance for the specified TRACKED class.
/// STATICDATA must be default-constructible.
- template<typename STATICDATA, class TRACKED>
+ template<typename STATICDATA, class TRACKED, class INST, InstanceTrackType TRACKEDTYPE>
static STATICDATA& getStatic()
{
- void *& instances = getInstances(typeid(TRACKED));
+ void *& instances = getInstances(TRACKEDTYPE);
if (! instances)
{
instances = new STATICDATA;
@@ -78,16 +104,16 @@ protected:
/// 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==T* case
-template<typename T, typename KEY = T*>
+template<typename T, enum InstanceTrackType TRACKED, typename KEY = T*>
class LLInstanceTracker : public LLInstanceTrackerBase
{
- typedef LLInstanceTracker<T, KEY> MyT;
+ typedef LLInstanceTracker<T, TRACKED, KEY> MyT;
typedef typename std::map<KEY, T*> InstanceMap;
struct StaticData: public StaticBase
{
InstanceMap sMap;
};
- static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); }
+ static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); }
static InstanceMap& getMap_() { return getStatic().sMap; }
public:
@@ -226,16 +252,16 @@ private:
/// explicit specialization for default case where KEY is T*
/// use a simple std::set<T*>
-template<typename T>
-class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase
+template<typename T, enum InstanceTrackType TRACKED>
+class LLInstanceTracker<T, TRACKED, T*> : public LLInstanceTrackerBase
{
- typedef LLInstanceTracker<T, T*> MyT;
+ typedef LLInstanceTracker<T, TRACKED, T*> MyT;
typedef typename std::set<T*> InstanceSet;
struct StaticData: public StaticBase
{
InstanceSet sSet;
};
- static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT>(); }
+ static StaticData& getStatic() { return LLInstanceTrackerBase::getStatic<StaticData, MyT, T, TRACKED>(); }
static InstanceSet& getSet_() { return getStatic().sSet; }
public:
diff --git a/indra/llcommon/llleap.h b/indra/llcommon/llleap.h
index 1a1ad23d39..d4e138f4be 100644
--- a/indra/llcommon/llleap.h
+++ b/indra/llcommon/llleap.h
@@ -29,9 +29,10 @@
* LLLeap* pointer should be validated before use by
* LLLeap::getInstance(LLLeap*) (see LLInstanceTracker).
*/
-class LL_COMMON_API LLLeap: public LLInstanceTracker<LLLeap>
+class LL_COMMON_API LLLeap: public INSTANCE_TRACKER(LLLeap)
{
public:
+
/**
* Pass a brief string description, mostly for logging purposes. The desc
* need not be unique, but obviously the clearer we can make it, the