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