diff options
| -rw-r--r-- | indra/llcommon/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | indra/llcommon/llapp.cpp | 2 | ||||
| -rw-r--r-- | indra/llcommon/lleventtimer.cpp | 95 | ||||
| -rw-r--r-- | indra/llcommon/lleventtimer.h | 61 | ||||
| -rw-r--r-- | indra/llcommon/lllivefile.cpp | 2 | ||||
| -rw-r--r-- | indra/llcommon/lltimer.cpp | 56 | ||||
| -rw-r--r-- | indra/llcommon/lltimer.h | 22 | 
7 files changed, 159 insertions, 80 deletions
| diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 9ead183a9e..5941bc5bb5 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -50,6 +50,7 @@ set(llcommon_SOURCE_FILES      lleventdispatcher.cpp      lleventfilter.cpp      llevents.cpp +    lleventtimer.cpp      llfasttimer_class.cpp      llfile.cpp      llfindlocale.cpp diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 968b92d1e7..6b2d1b7c20 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -41,7 +41,7 @@  #include "lllivefile.h"  #include "llmemory.h"  #include "llstl.h" // for DeletePointer() -#include "lltimer.h" +#include "lleventtimer.h"  //  // Signal handling diff --git a/indra/llcommon/lleventtimer.cpp b/indra/llcommon/lleventtimer.cpp new file mode 100644 index 0000000000..b2fdf11197 --- /dev/null +++ b/indra/llcommon/lleventtimer.cpp @@ -0,0 +1,95 @@ +/**  + * @file lleventtimer.cpp + * @brief Cross-platform objects for doing timing  + * + * $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 "linden_common.h" + +#include "lleventtimer.h" + +#include "u64.h" + + +////////////////////////////////////////////////////////////////////////////// +// +//		LLEventTimer Implementation +// +////////////////////////////////////////////////////////////////////////////// +bool LLEventTimer::sInTickLoop = false; + +LLEventTimer::LLEventTimer(F32 period) +: mEventTimer() +{ +	mPeriod = period; +} + +LLEventTimer::LLEventTimer(const LLDate& time) +: mEventTimer() +{ +	mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); +} + + +LLEventTimer::~LLEventTimer() +{ +	llassert(!LLEventTimer::sInTickLoop); // this LLEventTimer was destroyed from within its own tick() function - bad.  if you want tick() to cause destruction of its own timer, make it return true. +} + +//static +void LLEventTimer::updateClass()  +{ +	std::list<LLEventTimer*> completed_timers; +	LLEventTimer::sInTickLoop = true; +	for (instance_iter iter = beginInstances(); iter != 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 ); +			} +		} +	} +	LLEventTimer::sInTickLoop = false; + +	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; +		} +	} +} + + diff --git a/indra/llcommon/lleventtimer.h b/indra/llcommon/lleventtimer.h new file mode 100644 index 0000000000..f792138feb --- /dev/null +++ b/indra/llcommon/lleventtimer.h @@ -0,0 +1,61 @@ +/**  + * @file lleventtimer.h + * @brief Cross-platform objects for doing timing  + * + * $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$ + */ + +#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 : protected 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; +	static bool sInTickLoop; +}; + +#endif //LL_EVENTTIMER_H diff --git a/indra/llcommon/lllivefile.cpp b/indra/llcommon/lllivefile.cpp index effda6c49c..5ca90d82ba 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/lltimer.cpp b/indra/llcommon/lltimer.cpp index 900e122ea5..25b768079b 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -555,59 +555,3 @@ void secondsToTimecodeString(F32 current_time, std::string& tcstring)  } -////////////////////////////////////////////////////////////////////////////// -// -//		LLEventTimer Implementation -// -////////////////////////////////////////////////////////////////////////////// -bool LLEventTimer::sInTickLoop = false; - -LLEventTimer::LLEventTimer(F32 period) -: mEventTimer() -{ -	mPeriod = period; -} - -LLEventTimer::LLEventTimer(const LLDate& time) -: mEventTimer() -{ -	mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()); -} - - -LLEventTimer::~LLEventTimer() -{ -	llassert(!LLEventTimer::sInTickLoop); // this LLEventTimer was destroyed from within its own tick() function - bad.  if you want tick() to cause destruction of its own timer, make it return true. -} - -//static -void LLEventTimer::updateClass()  -{ -	std::list<LLEventTimer*> completed_timers; -	LLEventTimer::sInTickLoop = true; -	for (instance_iter iter = beginInstances(); iter != 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 ); -			} -		} -	} -	LLEventTimer::sInTickLoop = false; - -	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; -		} -	} -} - - diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h index 63e8121b58..baba95bfa1 100644 --- a/indra/llcommon/lltimer.h +++ b/indra/llcommon/lltimer.h @@ -39,8 +39,6 @@  #include <limits.h>  #include "stdtypes.h" -#include "lldate.h" -#include "llinstancetracker.h"  #include <string>  #include <list> @@ -171,26 +169,6 @@ LL_COMMON_API struct tm* utc_to_pacific_time(time_t utc_time, BOOL pacific_dayli  LL_COMMON_API void microsecondsToTimecodeString(U64 current_time, std::string& tcstring);  LL_COMMON_API void secondsToTimecodeString(F32 current_time, std::string& tcstring); -// class for scheduling a function to be called at a given frequency (approximate, inprecise) -class LL_COMMON_API LLEventTimer : protected 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; -	static bool sInTickLoop; -}; -  U64 LL_COMMON_API totalTime();					// Returns current system time in microseconds  #endif | 
