summaryrefslogtreecommitdiff
path: root/indra/llcommon/lleventtimer.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-25 11:56:44 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-25 11:56:44 -0400
commit55df7328c6f8c864ea309c57d73e791e079b3c2c (patch)
treecb4cba5e51d9649ba229c4eefeaafe783b9250e2 /indra/llcommon/lleventtimer.cpp
parent4b2b94f4864f2e2e7d76f4f17b2d58bb959b3edb (diff)
parent86d2fb93b73d2689104c564ec859be7f83416691 (diff)
Merge branch 'develop' into marchcat/xcode-16
Diffstat (limited to 'indra/llcommon/lleventtimer.cpp')
-rw-r--r--indra/llcommon/lleventtimer.cpp45
1 files changed, 20 insertions, 25 deletions
diff --git a/indra/llcommon/lleventtimer.cpp b/indra/llcommon/lleventtimer.cpp
index 33fafffefd..cc227193cd 100644
--- a/indra/llcommon/lleventtimer.cpp
+++ b/indra/llcommon/lleventtimer.cpp
@@ -25,49 +25,44 @@
*/
#include "linden_common.h"
-
#include "lleventtimer.h"
-#include "u64.h"
-
-
//////////////////////////////////////////////////////////////////////////////
//
// LLEventTimer Implementation
//
//////////////////////////////////////////////////////////////////////////////
-LLEventTimer::LLEventTimer(F32 period)
-: mEventTimer()
+LLEventTimer::LLEventTimer(F32 period):
+ mPeriod(period)
{
- mPeriod = period;
+ start();
}
-LLEventTimer::LLEventTimer(const LLDate& time)
-: mEventTimer()
+LLEventTimer::LLEventTimer(const LLDate& time):
+ LLEventTimer(F32(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch()))
+{}
+
+LLEventTimer::~LLEventTimer()
{
- mPeriod = (F32)(time.secondsSinceEpoch() - LLDate::now().secondsSinceEpoch());
}
-
-LLEventTimer::~LLEventTimer()
+void LLEventTimer::start()
{
+ mTimer = LL::Timers::instance().scheduleEvery([this]{ return tick(); }, mPeriod);
}
-//static
-void LLEventTimer::updateClass()
+void LLEventTimer::stop()
{
- for (auto& timer : instance_snapshot())
- {
- F32 et = timer.mEventTimer.getElapsedTimeF32();
- if (timer.mEventTimer.getStarted() && et > timer.mPeriod) {
- timer.mEventTimer.reset();
- if ( timer.tick() )
- {
- delete &timer;
- }
- }
- }
+ LL::Timers::instance().cancel(mTimer);
}
+bool LLEventTimer::isRunning()
+{
+ return LL::Timers::instance().isRunning(mTimer);
+}
+F32 LLEventTimer::getRemaining()
+{
+ return LL::Timers::instance().timeUntilCall(mTimer);
+}