summaryrefslogtreecommitdiff
path: root/indra/llcommon/lleventtimer.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-05-08 15:42:11 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-05-08 15:42:11 -0400
commitfe105060bb3fd75263c989e0fe6060280918d2bf (patch)
tree01591783e7310d60d00321e3fa48fe11858be541 /indra/llcommon/lleventtimer.cpp
parent51e86a0eff4e919075b32c498305add577450111 (diff)
parentdc0b3aed4782e4e4835fd6b9d59d1d70b78be4a7 (diff)
Merge branch 'nat/cleanup-timers' into lua-timers.
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 f575a7b6bf..1d2da93683 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().scheduleRepeating([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);
+}