diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 29fa35619..1c475b78f 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -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 diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 3bb833a94..c35a84255 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -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) diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index d5cf6ea93..05e2bccaf 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -131,6 +131,19 @@ public: */ bool parseCommandOptions(int argc, char** argv); + /** + * @brief Keep track of live files automatically. + * + * *TODO: it currently uses the addToEventTimer() 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 mLiveFiles; //@} private: diff --git a/indra/llcommon/llerrorthread.cpp b/indra/llcommon/llerrorthread.cpp index e2b106aa2..293379910 100644 --- a/indra/llcommon/llerrorthread.cpp +++ b/indra/llcommon/llerrorthread.cpp @@ -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"), diff --git a/indra/llcommon/lleventtimer.cpp b/indra/llcommon/lleventtimer.cpp new file mode 100644 index 000000000..2720b93ab --- /dev/null +++ b/indra/llcommon/lleventtimer.cpp @@ -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::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 completed_timers; + + /*{ + for (std::list::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::iterator completed_iter = completed_timers.begin(); + completed_iter != completed_timers.end(); + completed_iter++ ) + { + delete *completed_iter; + } + } +} + + diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h new file mode 100644 index 000000000..1521b507a --- /dev/null +++ b/indra/llcommon/lleventtimer.h @@ -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 +{ +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 sActiveList; // TODO should this be a vector +}; + + +#endif //LL_EVENTTIMER_H diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp new file mode 100644 index 000000000..293a1388f --- /dev/null +++ b/indra/llcommon/llinstancetracker.cpp @@ -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 instances; + + std::string k = info.name(); + if(instances.find(k) == instances.end()) + { + instances[k] = NULL; + } + + return instances[k]; +} diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h new file mode 100644 index 000000000..e4e535222 --- /dev/null +++ b/indra/llcommon/llinstancetracker.h @@ -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 + +#include "string_table.h" +#include +#include +#include +#include +#include + +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 +class LLInstanceTracker : public LLInstanceTrackerBase +{ + typedef typename std::map InstanceMap; + typedef LLInstanceTracker MyT; + typedef boost::function KeyGetter; + typedef boost::function InstancePtrGetter; +public: + /// Dereferencing key_iter gives you a const KEY& + typedef boost::transform_iterator key_iter; + /// Dereferencing instance_iter gives you a T& + typedef boost::indirect_iterator< boost::transform_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(this); + } + void remove_() + { + getMap_().erase(mKey); + } + + static InstanceMap& getMap_() + { + void * & instances = getInstances(typeid(MyT)); + if (! instances) + { + instances = new InstanceMap; + } + return * static_cast(instances); + } + +private: + + KEY mKey; +}; + +/// explicit specialization for default case where KEY is T* +/// use a simple std::set +template +class LLInstanceTracker : public LLInstanceTrackerBase +{ + typedef typename std::set InstanceSet; + typedef LLInstanceTracker 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 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(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(this)); + } + + LLInstanceTracker(const LLInstanceTracker& other) + { + //llassert(sIterationNestDepth == 0); + getSet_().insert(static_cast(this)); + } + + static InstanceSet& getSet_() + { + void * & instances = getInstances(typeid(MyT)); + if (! instances) + { + instances = new InstanceSet; + } + return * static_cast(instances); + } + + static S32 sIterationNestDepth; +}; + +template S32 LLInstanceTracker::sIterationNestDepth = 0; + +#endif diff --git a/indra/llcommon/llliveappconfig.cpp b/indra/llcommon/llliveappconfig.cpp index d2744875d..75bdfee8b 100644 --- a/indra/llcommon/llliveappconfig.cpp +++ b/indra/llcommon/llliveappconfig.cpp @@ -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; } diff --git a/indra/llcommon/llliveappconfig.h b/indra/llcommon/llliveappconfig.h index 465dde160..73b3a2335 100644 --- a/indra/llcommon/llliveappconfig.h +++ b/indra/llcommon/llliveappconfig.h @@ -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 + * live_config.checkAndReload() 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 diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index 322f226d5..ce6ac4fac 100644 --- a/indra/llcommon/lllivefile.cpp +++ b/indra/llcommon/lllivefile.cpp @@ -33,7 +33,7 @@ #include "lllivefile.h" #include "llframetimer.h" -#include "lltimer.h" +#include "lleventtimer.h" const F32 DEFAULT_CONFIG_FILE_REFRESH = 5.0f; diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp index 469e544b1..88c49a10c 100644 --- a/indra/llcommon/llprocessor.cpp +++ b/indra/llcommon/llprocessor.cpp @@ -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 diff --git a/indra/llcommon/llrun.h b/indra/llcommon/llrun.h index 0f8d51d81..1fc9925df 100644 --- a/indra/llcommon/llrun.h +++ b/indra/llcommon/llrun.h @@ -38,8 +38,6 @@ #include #include -#include "llpreprocessor.h" - class LLRunnable; /** diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index c0d47890c..34e19f83f 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -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::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 completed_timers; - for (std::list::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::iterator completed_iter = completed_timers.begin(); - completed_iter != completed_timers.end(); - completed_iter++ ) - { - delete *completed_iter; - } - } -} - diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 26734919c..68f06fdce 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -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 ×tr); LL_COMMON_API void timeStructToFormattedString(struct tm * time, std::string format, std::string ×tr); -// 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 sActiveList; // TODO should this be a vector -}; - #endif diff --git a/indra/llcommon/processor.h b/indra/llcommon/processor.h deleted file mode 100644 index 5ba55402b..000000000 --- a/indra/llcommon/processor.h +++ /dev/null @@ -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" diff --git a/indra/llcommon/timing.h b/indra/llcommon/timing.h index cfc637eb6..140ce1fca 100644 --- a/indra/llcommon/timing.h +++ b/indra/llcommon/timing.h @@ -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 diff --git a/indra/llui/lldelayeduidelete.h b/indra/llui/lldelayeduidelete.h index 2f08ee8fa..043e6972e 100644 --- a/indra/llui/lldelayeduidelete.h +++ b/indra/llui/lldelayeduidelete.h @@ -1,7 +1,7 @@ // #ifndef LL_LLDELAYEDUIDELETE_H #define LL_LLDELAYEDUIDELETE_H -#include "lltimer.h" +#include "lleventtimer.h" #include "llview.h" class LLDeleteJob { diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index bb379121c..4b325f54d 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -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" diff --git a/indra/llui/llui.h b/indra/llui/llui.h index c7b7446a0..abc9a298b 100644 --- a/indra/llui/llui.h +++ b/indra/llui/llui.h @@ -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 -class LLInstanceTracker : boost::noncopyable -{ -public: - typedef typename std::map::iterator instance_iter; - typedef typename std::map::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(this); - } - void remove() { sInstances.erase(mKey); } - -private: - - KEY mKey; - static std::map sInstances; -}; - -template -class LLInstanceTracker : boost::noncopyable -{ -public: - typedef typename std::set::iterator instance_iter; - typedef typename std::set::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(this)); } - virtual ~LLInstanceTracker() { sInstances.erase(static_cast(this)); } - - static std::set sInstances; -}; - -template std::map LLInstanceTracker::sInstances; -template std::set LLInstanceTracker::sInstances; - class LLCallbackRegistry { public: diff --git a/indra/newview/chatbar_as_cmdline.cpp b/indra/newview/chatbar_as_cmdline.cpp index 818df6279..e43a185c6 100644 --- a/indra/newview/chatbar_as_cmdline.cpp +++ b/indra/newview/chatbar_as_cmdline.cpp @@ -41,6 +41,7 @@ #include "llviewerregion.h" #include "llworld.h" #include "lluuid.h" +#include "lleventtimer.h" #include "llviewercontrol.h" #include "material_codes.h" diff --git a/indra/newview/floaterao.h b/indra/newview/floaterao.h index cf8ee2252..55cc7c052 100644 --- a/indra/newview/floaterao.h +++ b/indra/newview/floaterao.h @@ -5,6 +5,7 @@ #include "llfloater.h" #include "llviewercontrol.h" #include "llagent.h" +#include "lleventtimer.h" class AONoteCardDropTarget; diff --git a/indra/newview/floaterlocalassetbrowse.h b/indra/newview/floaterlocalassetbrowse.h index 6ee1c75a3..a727f9939 100644 --- a/indra/newview/floaterlocalassetbrowse.h +++ b/indra/newview/floaterlocalassetbrowse.h @@ -42,6 +42,7 @@ tag: vaa emerald local_asset_browser #include "llscrolllistctrl.h" #include "lltexturectrl.h" #include "lldrawable.h" +#include "lleventtimer.h" /*=======================================*/ diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 420a9ae67..b719ecc4e 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -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" diff --git a/indra/newview/llbuildnewviewsscheduler.h b/indra/newview/llbuildnewviewsscheduler.h index a3d5af66c..2f819288f 100644 --- a/indra/newview/llbuildnewviewsscheduler.h +++ b/indra/newview/llbuildnewviewsscheduler.h @@ -1,6 +1,7 @@ // #include "llinventoryview.h" #include "llinventory.h" +#include "lleventtimer.h" class LLBuildNewViewsScheduler : public LLEventTimer { typedef struct diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 9e79d93d7..8469bcda5 100644 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -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" diff --git a/indra/newview/llfloaterexploresounds.h b/indra/newview/llfloaterexploresounds.h index 11a181377..4bdcae820 100644 --- a/indra/newview/llfloaterexploresounds.h +++ b/indra/newview/llfloaterexploresounds.h @@ -5,6 +5,7 @@ #include "llfloater.h" #include "llaudioengine.h" +#include "lleventtimer.h" class LLFloaterExploreSounds : public LLFloater, public LLEventTimer diff --git a/indra/newview/llfloaterfriends.cpp b/indra/newview/llfloaterfriends.cpp index 255547933..2da7f7336 100644 --- a/indra/newview/llfloaterfriends.cpp +++ b/indra/newview/llfloaterfriends.cpp @@ -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" diff --git a/indra/newview/llfloaterfriends.h b/indra/newview/llfloaterfriends.h index 20c996d23..6454e9b55 100644 --- a/indra/newview/llfloaterfriends.h +++ b/indra/newview/llfloaterfriends.h @@ -38,7 +38,7 @@ #include "llpanel.h" #include "llstring.h" #include "lluuid.h" -#include "lltimer.h" +#include "lleventtimer.h" #include "llcallingcard.h" class LLFriendObserver; diff --git a/indra/newview/llfloatermessagelog.cpp b/indra/newview/llfloatermessagelog.cpp index 3ee8018ad..74241d35e 100644 --- a/indra/newview/llfloatermessagelog.cpp +++ b/indra/newview/llfloatermessagelog.cpp @@ -10,6 +10,7 @@ #include "llmessagetemplate.h" #include #include "llmenugl.h" +#include "lleventtimer.h" #include "llagent.h" diff --git a/indra/newview/llfloatermessagelog.h b/indra/newview/llfloatermessagelog.h index 104f57ebb..1fa01c5af 100644 --- a/indra/newview/llfloatermessagelog.h +++ b/indra/newview/llfloatermessagelog.h @@ -2,6 +2,7 @@ #include "llfloater.h" #include "llmessagelog.h" #include "lltemplatemessagereader.h" +#include "lleventtimer.h" class LLNetListItem { diff --git a/indra/newview/llnotify.cpp b/indra/newview/llnotify.cpp index 9a36b6542..ffd264b6c 100644 --- a/indra/newview/llnotify.cpp +++ b/indra/newview/llnotify.cpp @@ -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::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::getInstance(notification->getID()); if (boxp && !boxp->isDead()) { boxp->close(); diff --git a/indra/newview/llnotify.h b/indra/newview/llnotify.h index 15b5a7302..439cae239 100644 --- a/indra/newview/llnotify.h +++ b/indra/newview/llnotify.h @@ -35,7 +35,7 @@ #include "llfontgl.h" #include "llpanel.h" -#include "lltimer.h" +#include "lleventtimer.h" #include "llnotifications.h" #include diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index 58959e445..6f6ddcac2 100644 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -40,7 +40,7 @@ #include "llcombobox.h" #include "lliconctrl.h" #include "llframetimer.h" -#include "lltimer.h" +#include "lleventtimer.h" class LLMessageSystem; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 6c66831c9..81e2abc5a 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -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" diff --git a/indra/newview/llviewerparcelmediaautoplay.h b/indra/newview/llviewerparcelmediaautoplay.h index 16279e7f1..243da2f38 100644 --- a/indra/newview/llviewerparcelmediaautoplay.h +++ b/indra/newview/llviewerparcelmediaautoplay.h @@ -33,7 +33,7 @@ #ifndef LLVIEWERPARCELMEDIAAUTOPLAY_H #define LLVIEWERPARCELMEDIAAUTOPLAY_H -#include "lltimer.h" +#include "lleventtimer.h" // timer to automatically play media class LLViewerParcelMediaAutoPlay : LLEventTimer diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h index 362200aec..69f8ad703 100644 --- a/indra/newview/rlvhandler.h +++ b/indra/newview/rlvhandler.h @@ -22,6 +22,7 @@ #include "llstartup.h" #include "llviewerjointattachment.h" #include "llviewerobject.h" +#include "lleventtimer.h" #include "rlvcommon.h" #include "rlvhelper.h" diff --git a/indra/newview/rlvhelper.h b/indra/newview/rlvhelper.h index 165797b92..74b527f70 100644 --- a/indra/newview/rlvhelper.h +++ b/indra/newview/rlvhelper.h @@ -24,6 +24,7 @@ #include "llviewerinventory.h" #include "llvoavatar.h" #include "llwlparamset.h" +#include "lleventtimer.h" #include "rlvdefines.h" #include "rlvcommon.h" diff --git a/indra/newview/rlvlocks.h b/indra/newview/rlvlocks.h index e54caa30a..c4139b135 100644 --- a/indra/newview/rlvlocks.h +++ b/indra/newview/rlvlocks.h @@ -28,6 +28,7 @@ #include "llviewerjointattachment.h" #include "llviewerobject.h" #include "llvoavatar.h" +#include "lleventtimer.h" #include "rlvdefines.h"