Pulled LLEventTimer out of lltimer.h/cpp and into lleventtimer.h/cpp

LLInstanceTracker added to llcommon (pulled from llui in v2 for usage elsewhere)
LLEventTimer now using LLInstanceTracker
Updated LLLiveAppConfig (Though it appears unused, really)
processor.h is obsolete, thus removed. (llprocessor.h replaces it)
This commit is contained in:
Shyotl
2011-05-15 22:40:59 -05:00
parent e3435d7ef9
commit 51338470b5
39 changed files with 535 additions and 201 deletions

View File

@@ -32,6 +32,7 @@ set(llcommon_SOURCE_FILES
llerror.cpp
llerrorthread.cpp
llevent.cpp
lleventtimer.cpp
llfasttimer.cpp
llfile.cpp
llfindlocale.cpp
@@ -39,6 +40,7 @@ set(llcommon_SOURCE_FILES
llformat.cpp
llframetimer.cpp
llheartbeat.cpp
llinstancetracker.cpp
llindraconfigfile.cpp
llliveappconfig.cpp
lllivefile.cpp
@@ -122,6 +124,7 @@ set(llcommon_HEADER_FILES
llevent.h
lleventemitter.h
llextendedstatus.h
lleventtimer.h
llfasttimer.h
llfile.h
llfindlocale.h
@@ -132,6 +135,7 @@ set(llcommon_HEADER_FILES
llheartbeat.h
llhttpstatuscodes.h
llindexedqueue.h
llinstancetracker.h
llindraconfigfile.h
llkeythrottle.h
lllinkedqueue.h
@@ -188,7 +192,6 @@ set(llcommon_HEADER_FILES
metaclasst.h
metaproperty.h
metapropertyt.h
processor.h
reflective.h
reflectivet.h
roles_constants.h

View File

@@ -38,8 +38,10 @@
#include "llerrorcontrol.h"
#include "llerrorthread.h"
#include "llframetimer.h"
#include "lllivefile.h"
#include "llmemory.h"
#include "lltimer.h"
#include "llstl.h" // for DeletePointer()
#include "lleventtimer.h"
//
// Signal handling
@@ -139,6 +141,11 @@ LLApp::~LLApp()
delete sSigChildCount;
sSigChildCount = NULL;
#endif
// reclaim live file memory
std::for_each(mLiveFiles.begin(), mLiveFiles.end(), DeletePointer());
mLiveFiles.clear();
setStopped();
// HACK: wait for the error thread to clean itself
ms_sleep(20);
@@ -212,6 +219,15 @@ bool LLApp::parseCommandOptions(int argc, char** argv)
return true;
}
void LLApp::manageLiveFile(LLLiveFile* livefile)
{
if(!livefile) return;
livefile->checkAndReload();
livefile->addToEventTimer();
mLiveFiles.push_back(livefile);
}
bool LLApp::setOptionData(OptionPriority level, LLSD data)
{
if((level < 0)

View File

@@ -131,6 +131,19 @@ public:
*/
bool parseCommandOptions(int argc, char** argv);
/**
* @brief Keep track of live files automatically.
*
* *TODO: it currently uses the <code>addToEventTimer()</code> API
* instead of the runner. I should probalby use the runner.
*
* *NOTE: DO NOT add the livefile instance to any kind of check loop.
*
* @param livefile A valid instance of an LLLiveFile. This LLApp
* instance will delete the livefile instance.
*/
void manageLiveFile(LLLiveFile* livefile);
/**
* @brief Set the options at the specified priority.
*
@@ -285,6 +298,8 @@ private:
// The application options.
LLSD mOptions;
// The live files for this application
std::vector<LLLiveFile*> mLiveFiles;
//@}
private:

View File

@@ -32,7 +32,7 @@
#include "linden_common.h"
#include "llerrorthread.h"
#include "llapp.h"
#include "lltimer.h"
#include "lltimer.h" // ms_sleep()
LLErrorThread::LLErrorThread()
: LLThread("Error"),

View File

@@ -0,0 +1,115 @@
/**
* @file lleventtimer.cpp
* @brief Cross-platform objects for doing timing
*
* $LicenseInfo:firstyear=2000&license=viewergpl$
*
* Copyright (c) 2000-2010, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*
*/
#include "linden_common.h"
#include "lleventtimer.h"
#include "u64.h"
//////////////////////////////////////////////////////////////////////////////
//
// LLEventTimer Implementation
//
//////////////////////////////////////////////////////////////////////////////
//std::list<LLEventTimer*> LLEventTimer::sActiveList;
LLEventTimer::LLEventTimer(F32 period)
: mEventTimer()
{
mPeriod = period;
//sActiveList.push_back(this);
}
LLEventTimer::LLEventTimer(const LLDate& time)
: mEventTimer()
{
mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch());
//sActiveList.push_back(this);
}
LLEventTimer::~LLEventTimer()
{
//sActiveList.remove(this);
}
//static
void LLEventTimer::updateClass()
{
std::list<LLEventTimer*> completed_timers;
/*{
for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); )
{
LLEventTimer* timer = *iter++;
F32 et = timer->mEventTimer.getElapsedTimeF32();
if (timer->mEventTimer.getStarted() && et > timer->mPeriod) {
timer->mEventTimer.reset();
if ( timer->tick() )
{
completed_timers.push_back( timer );
}
}
}
}*/
{
LLInstanceTrackerScopedGuard guard;
for (instance_iter iter = guard.beginInstances(); iter != guard.endInstances(); )
{
LLEventTimer& timer = *iter++;
F32 et = timer.mEventTimer.getElapsedTimeF32();
if (timer.mEventTimer.getStarted() && et > timer.mPeriod) {
timer.mEventTimer.reset();
if ( timer.tick() )
{
completed_timers.push_back( &timer );
}
}
}
}
if ( completed_timers.size() > 0 )
{
for (std::list<LLEventTimer*>::iterator completed_iter = completed_timers.begin();
completed_iter != completed_timers.end();
completed_iter++ )
{
delete *completed_iter;
}
}
}

View File

@@ -0,0 +1,66 @@
/**
* @file lleventtimer.h
* @brief Cross-platform objects for doing timing
*
* $LicenseInfo:firstyear=2000&license=viewergpl$
*
* Copyright (c) 2000-2010, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*
*/
#ifndef LL_EVENTTIMER_H
#define LL_EVENTTIMER_H
#include "stdtypes.h"
#include "lldate.h"
#include "llinstancetracker.h"
#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>
{
public:
LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds
LLEventTimer(const LLDate& time);
virtual ~LLEventTimer();
//function to be called at the supplied frequency
// Normally return FALSE; TRUE will delete the timer after the function returns.
virtual BOOL tick() = 0;
static void updateClass();
protected:
LLTimer mEventTimer;
F32 mPeriod;
//private:
//list of active timers
// static std::list<LLEventTimer*> sActiveList; // TODO should this be a vector
};
#endif //LL_EVENTTIMER_H

View File

@@ -0,0 +1,47 @@
/**
* @file lllinstancetracker.cpp
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
// Precompiled header
#include "linden_common.h"
// associated header
#include "llinstancetracker.h"
// STL headers
// std headers
// external library headers
// other Linden headers
//static
void * & LLInstanceTrackerBase::getInstances(std::type_info const & info)
{
static std::map<std::string, void *> instances;
std::string k = info.name();
if(instances.find(k) == instances.end())
{
instances[k] = NULL;
}
return instances[k];
}

View File

@@ -0,0 +1,202 @@
/**
* @file llinstancetracker.h
* @brief LLInstanceTracker is a mixin class that automatically tracks object
* instances with or without an associated key
*
* $LicenseInfo:firstyear=2000&license=viewergpl$
*
* Copyright (c) 2000-2010, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlife.com/developers/opensource/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlife.com/developers/opensource/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*
*/
#ifndef LL_LLINSTANCETRACKER_H
#define LL_LLINSTANCETRACKER_H
#include <map>
#include "string_table.h"
#include <boost/utility.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/iterator/indirect_iterator.hpp>
class LL_COMMON_API LLInstanceTrackerBase : public boost::noncopyable
{
protected:
static void * & getInstances(std::type_info const & info);
};
/// 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==T* case
template<typename T, typename KEY = T*>
class LLInstanceTracker : public LLInstanceTrackerBase
{
typedef typename std::map<KEY, T*> InstanceMap;
typedef LLInstanceTracker<T, KEY> MyT;
typedef boost::function<const KEY&(typename InstanceMap::value_type&)> KeyGetter;
typedef boost::function<T*(typename InstanceMap::value_type&)> InstancePtrGetter;
public:
/// Dereferencing key_iter gives you a const KEY&
typedef boost::transform_iterator<KeyGetter, typename InstanceMap::iterator> key_iter;
/// Dereferencing instance_iter gives you a T&
typedef boost::indirect_iterator< boost::transform_iterator<InstancePtrGetter, typename InstanceMap::iterator> > instance_iter;
static T* getInstance(const KEY& k)
{
typename InstanceMap::const_iterator found = getMap_().find(k);
return (found == getMap_().end()) ? NULL : found->second;
}
static key_iter beginKeys()
{
return boost::make_transform_iterator(getMap_().begin(),
boost::bind(&InstanceMap::value_type::first, _1));
}
static key_iter endKeys()
{
return boost::make_transform_iterator(getMap_().end(),
boost::bind(&InstanceMap::value_type::first, _1));
}
static instance_iter beginInstances()
{
return instance_iter(boost::make_transform_iterator(getMap_().begin(),
boost::bind(&InstanceMap::value_type::second, _1)));
}
static instance_iter endInstances()
{
return instance_iter(boost::make_transform_iterator(getMap_().end(),
boost::bind(&InstanceMap::value_type::second, _1)));
}
static S32 instanceCount() { return getMap_().size(); }
protected:
LLInstanceTracker(KEY key) { add_(key); }
virtual ~LLInstanceTracker() { remove_(); }
virtual void setKey(KEY key) { remove_(); add_(key); }
virtual const KEY& getKey() const { return mKey; }
private:
void add_(KEY key)
{
mKey = key;
getMap_()[key] = static_cast<T*>(this);
}
void remove_()
{
getMap_().erase(mKey);
}
static InstanceMap& getMap_()
{
void * & instances = getInstances(typeid(MyT));
if (! instances)
{
instances = new InstanceMap;
}
return * static_cast<InstanceMap*>(instances);
}
private:
KEY mKey;
};
/// explicit specialization for default case where KEY is T*
/// use a simple std::set<T*>
template<typename T>
class LLInstanceTracker<T, T*> : public LLInstanceTrackerBase
{
typedef typename std::set<T*> InstanceSet;
typedef LLInstanceTracker<T, T*> MyT;
public:
/// Dereferencing key_iter gives you a T* (since T* is the key)
typedef typename InstanceSet::iterator key_iter;
/// Dereferencing instance_iter gives you a T&
typedef boost::indirect_iterator<key_iter> instance_iter;
/// for completeness of analogy with the generic implementation
static T* getInstance(T* k) { return k; }
static S32 instanceCount() { return getSet_().size(); }
// Instantiate this to get access to iterators for this type. It's a 'guard' in the sense
// that it treats deletes of this type as errors as long as there is an instance of
// this class alive in scope somewhere (i.e. deleting while iterating is bad).
class LLInstanceTrackerScopedGuard
{
public:
LLInstanceTrackerScopedGuard()
{
++sIterationNestDepth;
}
~LLInstanceTrackerScopedGuard()
{
--sIterationNestDepth;
}
static instance_iter beginInstances() { return instance_iter(getSet_().begin()); }
static instance_iter endInstances() { return instance_iter(getSet_().end()); }
static key_iter beginKeys() { return getSet_().begin(); }
static key_iter endKeys() { return getSet_().end(); }
};
protected:
LLInstanceTracker()
{
// it's safe but unpredictable to create instances of this type while all instances are being iterated over. I hate unpredictable. This assert will probably be turned on early in the next development cycle.
//llassert(sIterationNestDepth == 0);
getSet_().insert(static_cast<T*>(this));
}
virtual ~LLInstanceTracker()
{
// it's unsafe to delete instances of this type while all instances are being iterated over.
llassert(sIterationNestDepth == 0);
getSet_().erase(static_cast<T*>(this));
}
LLInstanceTracker(const LLInstanceTracker& other)
{
//llassert(sIterationNestDepth == 0);
getSet_().insert(static_cast<T*>(this));
}
static InstanceSet& getSet_()
{
void * & instances = getInstances(typeid(MyT));
if (! instances)
{
instances = new InstanceSet;
}
return * static_cast<InstanceSet *>(instances);
}
static S32 sIterationNestDepth;
};
template <typename T> S32 LLInstanceTracker<T, T*>::sIterationNestDepth = 0;
#endif

View File

@@ -38,9 +38,12 @@
#include "llsd.h"
#include "llsdserialize.h"
LLLiveAppConfig::LLLiveAppConfig(LLApp* app, const std::string& filename, F32 refresh_period)
: LLLiveFile(filename, refresh_period),
mApp(app)
LLLiveAppConfig::LLLiveAppConfig(
const std::string& filename,
F32 refresh_period,
LLApp::OptionPriority priority) :
LLLiveFile(filename, refresh_period),
mPriority(priority)
{ }
@@ -77,7 +80,7 @@ bool LLLiveAppConfig::loadFile()
// to set the config to an empty config, and return that it
// changed.
mApp->setOptionData(
LLApp::PRIORITY_SPECIFIC_CONFIGURATION, config);
LLApp* app = LLApp::instance();
if(app) app->setOptionData(mPriority, config);
return true;
}

View File

@@ -33,25 +33,43 @@
#ifndef LLLIVEAPPCONFIG_H
#define LLLIVEAPPCONFIG_H
#include "llapp.h"
#include "lllivefile.h"
class LLApp;
/**
* @class LLLiveAppConfig
* @see LLLiveFile
*
* To use this, instantiate a LLLiveAppConfig object inside your main
* loop. The traditional name for it is live_config. Be sure to call
* <code>live_config.checkAndReload()</code> periodically.
*/
class LL_COMMON_API LLLiveAppConfig : public LLLiveFile
{
public:
// To use this, instantiate a LLLiveAppConfig object inside your main loop.
// The traditional name for it is live_config.
// Be sure to call live_config.checkAndReload() periodically.
LLLiveAppConfig(LLApp* app, const std::string& filename, F32 refresh_period);
~LLLiveAppConfig();
/**
* @brief Constructor
*
* @param filename. The name of the file for periodically checking
* configuration.
* @param refresh_period How often the internal timer should
* bother checking the filesystem.
* @param The application priority level of that configuration file.
*/
LLLiveAppConfig(
const std::string& filename,
F32 refresh_period,
LLApp::OptionPriority priority);
~LLLiveAppConfig(); ///< Destructor
protected:
/*virtual*/ bool loadFile();
private:
LLApp* mApp;
LLApp::OptionPriority mPriority;
};
#endif

View File

@@ -33,7 +33,7 @@
#include "lllivefile.h"
#include "llframetimer.h"
#include "lltimer.h"
#include "lleventtimer.h"
const F32 DEFAULT_CONFIG_FILE_REFRESH = 5.0f;

View File

@@ -47,10 +47,8 @@
// solving some compiler conversion problems
// - Fixed a bug at family=6, model=6 (Celeron -> P2)
//////////////////////////////////////////////////////////////////////////////////
#include "linden_common.h"
#include "processor.h"
#include "llprocessor.h"
#include <memory>

View File

@@ -38,8 +38,6 @@
#include <vector>
#include <boost/shared_ptr.hpp>
#include "llpreprocessor.h"
class LLRunnable;
/**

View File

@@ -33,7 +33,6 @@
#include "linden_common.h"
#include "lltimer.h"
#include "timing.h" // totalTime prototype.
#include "u64.h"
@@ -52,6 +51,9 @@
//
// Locally used constants
//
const U32 SEC_PER_DAY = 86400;
const F64 SEC_TO_MICROSEC = 1000000.f;
const U64 SEC_TO_MICROSEC_U64 = 1000000;
const F64 USEC_TO_SEC_F64 = 0.000001;
@@ -571,59 +573,6 @@ void timeStructToFormattedString(struct tm * time, std::string format, std::stri
}
//////////////////////////////////////////////////////////////////////////////
//
// LLEventTimer Implementation
//
//////////////////////////////////////////////////////////////////////////////
std::list<LLEventTimer*> LLEventTimer::sActiveList;
LLEventTimer::LLEventTimer(F32 period)
: mEventTimer()
{
mPeriod = period;
sActiveList.push_back(this);
}
LLEventTimer::LLEventTimer(const LLDate& time)
: mEventTimer()
{
mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch());
sActiveList.push_back(this);
}
LLEventTimer::~LLEventTimer()
{
sActiveList.remove(this);
}
void LLEventTimer::updateClass()
{
std::list<LLEventTimer*> completed_timers;
for (std::list<LLEventTimer*>::iterator iter = sActiveList.begin(); iter != sActiveList.end(); )
{
LLEventTimer* timer = *iter++;
F32 et = timer->mEventTimer.getElapsedTimeF32();
if (timer->mEventTimer.getStarted() && et > timer->mPeriod) {
timer->mEventTimer.reset();
if ( timer->tick() )
{
completed_timers.push_back( timer );
}
}
}
if ( completed_timers.size() > 0 )
{
for (std::list<LLEventTimer*>::iterator completed_iter = completed_timers.begin();
completed_iter != completed_timers.end();
completed_iter++ )
{
delete *completed_iter;
}
}
}

View File

@@ -55,6 +55,8 @@ const U32 USEC_PER_HOUR = USEC_PER_MIN * MIN_PER_HOUR;
const U32 SEC_PER_HOUR = SEC_PER_MIN * MIN_PER_HOUR;
const F64 SEC_PER_USEC = 1.0 / (F64) USEC_PER_SEC;
LL_COMMON_API U64 totalTime(); // Returns current system time in microseconds
class LL_COMMON_API LLTimer
{
public:
@@ -155,7 +157,7 @@ static inline time_t time_max()
}
// Correction factor used by time_corrected() above.
LL_COMMON_API extern S32 gUTCOffset;
extern LL_COMMON_API S32 gUTCOffset;
// Is the current computer (in its current time zone)
// observing daylight savings time?
@@ -173,27 +175,4 @@ LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstri
LL_COMMON_API void timeToFormattedString(time_t time, std::string format, std::string &timestr);
LL_COMMON_API void timeStructToFormattedString(struct tm * time, std::string format, std::string &timestr);
// class for scheduling a function to be called at a given frequency (approximate, inprecise)
class LL_COMMON_API LLEventTimer
{
public:
LLEventTimer(F32 period); // period is the amount of time between each call to tick() in seconds
LLEventTimer(const LLDate& time);
virtual ~LLEventTimer();
//function to be called at the supplied frequency
// Normally return FALSE; TRUE will delete the timer after the function returns.
virtual BOOL tick() = 0;
static void updateClass();
protected:
LLTimer mEventTimer;
F32 mPeriod;
private:
//list of active timers
static std::list<LLEventTimer*> sActiveList; // TODO should this be a vector
};
#endif

View File

@@ -1,33 +0,0 @@
/**
* @file processor.h
* @brief Legacy wrapper header.
*
* $LicenseInfo:firstyear=2000&license=viewergpl$
*
* Copyright (c) 2000-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. Terms of
* the GPL can be found in doc/GPL-license.txt in this distribution, or
* online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
*
* There are special exceptions to the terms and conditions of the GPL as
* it is applied to this Source Code. View the full text of the exception
* in the file doc/FLOSS-exception.txt in this software distribution, or
* online at
* http://secondlifegrid.net/programs/open_source/licensing/flossexception
*
* By copying, modifying or distributing this software, you acknowledge
* that you have read and understood your obligations described above,
* and agree to abide by those obligations.
*
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
#include "llprocessor.h"

View File

@@ -43,7 +43,6 @@ const F32 SEC_TO_MICROSEC = 1000000.f;
const U64 SEC_TO_MICROSEC_U64 = 1000000;
const U32 SEC_PER_DAY = 86400;
// This is just a stub, implementation in lltimer.cpp. This file will be deprecated in the future.
LL_COMMON_API U64 totalTime(); // Returns current system time in microseconds
// functionality has been moved lltimer.{cpp,h}. This file will be deprecated in the future.
#endif

View File

@@ -1,7 +1,7 @@
// <edit>
#ifndef LL_LLDELAYEDUIDELETE_H
#define LL_LLDELAYEDUIDELETE_H
#include "lltimer.h"
#include "lleventtimer.h"
#include "llview.h"
class LLDeleteJob
{

View File

@@ -96,6 +96,7 @@
// we want to minimize external dependencies, but this one is important
#include "llsd.h"
#include "llinstancetracker.h"
// and we need this to manage the notification callbacks
#include "llfunctorregistry.h"

View File

@@ -602,62 +602,6 @@ public:
virtual void cleanUp() = 0;
};
// This mix-in class adds support for tracking all instances of the specificed 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 list
template<typename T, typename KEY = T*>
class LLInstanceTracker : boost::noncopyable
{
public:
typedef typename std::map<KEY, T*>::iterator instance_iter;
typedef typename std::map<KEY, T*>::const_iterator instance_const_iter;
static T* getInstance(KEY k) { instance_iter found = sInstances.find(k); return (found == sInstances.end()) ? NULL : found->second; }
static instance_iter beginInstances() { return sInstances.begin(); }
static instance_iter endInstances() { return sInstances.end(); }
static S32 instanceCount() { return sInstances.size(); }
protected:
LLInstanceTracker(KEY key) { add(key); }
virtual ~LLInstanceTracker() { remove(); }
virtual void setKey(KEY key) { remove(); add(key); }
virtual const KEY& getKey() const { return mKey; }
private:
void add(KEY key)
{
mKey = key;
sInstances[key] = static_cast<T*>(this);
}
void remove() { sInstances.erase(mKey); }
private:
KEY mKey;
static std::map<KEY, T*> sInstances;
};
template<typename T>
class LLInstanceTracker<T, T*> : boost::noncopyable
{
public:
typedef typename std::set<T*>::iterator instance_iter;
typedef typename std::set<T*>::const_iterator instance_const_iter;
static instance_iter instancesBegin() { return sInstances.begin(); }
static instance_iter instancesEnd() { return sInstances.end(); }
static S32 instanceCount() { return sInstances.size(); }
protected:
LLInstanceTracker() { sInstances.insert(static_cast<T*>(this)); }
virtual ~LLInstanceTracker() { sInstances.erase(static_cast<T*>(this)); }
static std::set<T*> sInstances;
};
template <typename T, typename KEY> std::map<KEY, T*> LLInstanceTracker<T, KEY>::sInstances;
template <typename T> std::set<T*> LLInstanceTracker<T, T*>::sInstances;
class LLCallbackRegistry
{
public:

View File

@@ -41,6 +41,7 @@
#include "llviewerregion.h"
#include "llworld.h"
#include "lluuid.h"
#include "lleventtimer.h"
#include "llviewercontrol.h"
#include "material_codes.h"

View File

@@ -5,6 +5,7 @@
#include "llfloater.h"
#include "llviewercontrol.h"
#include "llagent.h"
#include "lleventtimer.h"
class AONoteCardDropTarget;

View File

@@ -42,6 +42,7 @@ tag: vaa emerald local_asset_browser
#include "llscrolllistctrl.h"
#include "lltexturectrl.h"
#include "lldrawable.h"
#include "lleventtimer.h"
/*=======================================*/

View File

@@ -44,6 +44,7 @@
#include "lltexteditor.h"
#include "llalertdialog.h"
#include "llerrorcontrol.h"
#include "lleventtimer.h"
#include "llviewertexturelist.h"
#include "llgroupmgr.h"
#include "llagent.h"

View File

@@ -1,6 +1,7 @@
// <edit>
#include "llinventoryview.h"
#include "llinventory.h"
#include "lleventtimer.h"
class LLBuildNewViewsScheduler : public LLEventTimer
{
typedef struct

View File

@@ -39,8 +39,9 @@
#include "llhttpclient.h"
#include "llhttpstatuscodes.h"
#include "llsdserialize.h"
#include "llsdutil.h"
#include "lltimer.h"
#include "lleventtimer.h"
#include "llsdutil.h"
#include "llviewerregion.h"
#include "message.h"
#include "lltrans.h"

View File

@@ -5,6 +5,7 @@
#include "llfloater.h"
#include "llaudioengine.h"
#include "lleventtimer.h"
class LLFloaterExploreSounds
: public LLFloater, public LLEventTimer

View File

@@ -62,7 +62,7 @@
#include "llmenucommands.h"
#include "llviewercontrol.h"
#include "llviewermessage.h"
#include "lltimer.h"
#include "lleventtimer.h"
#include "lltextbox.h"
#include "llvoiceclient.h"

View File

@@ -38,7 +38,7 @@
#include "llpanel.h"
#include "llstring.h"
#include "lluuid.h"
#include "lltimer.h"
#include "lleventtimer.h"
#include "llcallingcard.h"
class LLFriendObserver;

View File

@@ -10,6 +10,7 @@
#include "llmessagetemplate.h"
#include <boost/tokenizer.hpp>
#include "llmenugl.h"
#include "lleventtimer.h"
#include "llagent.h"

View File

@@ -2,6 +2,7 @@
#include "llfloater.h"
#include "llmessagelog.h"
#include "lltemplatemessagereader.h"
#include "lleventtimer.h"
class LLNetListItem
{

View File

@@ -99,7 +99,9 @@ bool LLNotifyBox::onNotification(const LLSD& notify)
if(notify["sigtype"].asString() == "add" || notify["sigtype"].asString() == "change")
{
//bring existing notification to top
LLNotifyBox* boxp = LLNotifyBox::getInstance(notification->getID());
//This getInstance is ugly, as LLNotifyBox is derived from both LLInstanceTracker and LLEventTimer, which also is derived from its own LLInstanceTracker
//Have to explicitly determine which getInstance function to use.
LLNotifyBox* boxp = LLNotifyBox::LLInstanceTracker<LLNotifyBox, LLUUID>::getInstance(notification->getID());
if (boxp && !boxp->isDead())
{
gNotifyBoxView->showOnly(boxp);
@@ -116,7 +118,7 @@ bool LLNotifyBox::onNotification(const LLSD& notify)
}
else if (notify["sigtype"].asString() == "delete")
{
LLNotifyBox* boxp = LLNotifyBox::getInstance(notification->getID());
LLNotifyBox* boxp = LLNotifyBox::LLInstanceTracker<LLNotifyBox, LLUUID>::getInstance(notification->getID());
if (boxp && !boxp->isDead())
{
boxp->close();

View File

@@ -35,7 +35,7 @@
#include "llfontgl.h"
#include "llpanel.h"
#include "lltimer.h"
#include "lleventtimer.h"
#include "llnotifications.h"
#include <vector>

View File

@@ -40,7 +40,7 @@
#include "llcombobox.h"
#include "lliconctrl.h"
#include "llframetimer.h"
#include "lltimer.h"
#include "lleventtimer.h"
class LLMessageSystem;

View File

@@ -64,7 +64,7 @@
#include "llxfermanager.h"
#include "message.h"
#include "sound_ids.h"
#include "lltimer.h"
#include "lleventtimer.h"
#include "llmd5.h"
#include "llagent.h"

View File

@@ -33,7 +33,7 @@
#ifndef LLVIEWERPARCELMEDIAAUTOPLAY_H
#define LLVIEWERPARCELMEDIAAUTOPLAY_H
#include "lltimer.h"
#include "lleventtimer.h"
// timer to automatically play media
class LLViewerParcelMediaAutoPlay : LLEventTimer

View File

@@ -22,6 +22,7 @@
#include "llstartup.h"
#include "llviewerjointattachment.h"
#include "llviewerobject.h"
#include "lleventtimer.h"
#include "rlvcommon.h"
#include "rlvhelper.h"

View File

@@ -24,6 +24,7 @@
#include "llviewerinventory.h"
#include "llvoavatar.h"
#include "llwlparamset.h"
#include "lleventtimer.h"
#include "rlvdefines.h"
#include "rlvcommon.h"

View File

@@ -28,6 +28,7 @@
#include "llviewerjointattachment.h"
#include "llviewerobject.h"
#include "llvoavatar.h"
#include "lleventtimer.h"
#include "rlvdefines.h"