summaryrefslogtreecommitdiff
path: root/indra/llcommon/lldeadmantimer.cpp
diff options
context:
space:
mode:
authorMonty Brandenberg <monty@lindenlab.com>2013-04-10 16:30:26 +0000
committerMonty Brandenberg <monty@lindenlab.com>2013-04-10 16:30:26 +0000
commitaabda8f3073928980b26530eac9b05eeb85a2207 (patch)
tree79a4903504f4620ce6914c9a0aa39b41705a36bc /indra/llcommon/lldeadmantimer.cpp
parent188221a90c7a054d390ddaa534d391f6370ac6bc (diff)
SH-4089 Unit test work for timer. Knocked off some tests for
the deadman's timer. Found some bugs, dig some cleanup and documented a few things. Definitely want to get rid of the U64/F64 interfaces at sometime but this is a good start.
Diffstat (limited to 'indra/llcommon/lldeadmantimer.cpp')
-rw-r--r--indra/llcommon/lldeadmantimer.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/indra/llcommon/lldeadmantimer.cpp b/indra/llcommon/lldeadmantimer.cpp
index 2f48d13c2d..3d3f738c06 100644
--- a/indra/llcommon/lldeadmantimer.cpp
+++ b/indra/llcommon/lldeadmantimer.cpp
@@ -29,8 +29,21 @@
#include "lldeadmantimer.h"
+// *TODO: Currently, this uses lltimer functions for its time
+// aspects and this leaks into the apis in the U64s/F64s. Would
+// like to perhaps switch this over to TSC register-based timers
+// sometime and drop the overhead some more.
+
+
+// Flag states and their meaning:
+// mActive mDone Meaning
+// false false Nothing running, no result available
+// true false Timer running, no result available
+// false true Timer finished, result can be read once
+// true true Not allowed
+//
LLDeadmanTimer::LLDeadmanTimer(F64 horizon)
- : mHorizon(U64(horizon * gClockFrequency)),
+ : mHorizon(U64(llmax(horizon, F64(0.0)) * gClockFrequency)),
mActive(false), // If true, a timer is running.
mDone(false), // If true, timer has completed and can be read (once)
mStarted(U64L(0)),
@@ -78,19 +91,14 @@ void LLDeadmanTimer::stop(U64 now)
bool LLDeadmanTimer::isExpired(F64 & started, F64 & stopped, U64 & count, U64 now)
{
- if (! mActive)
- {
- return false;
- }
-
- if (! mDone)
+ if (mActive && ! mDone)
{
if (! now)
{
now = LLTimer::getCurrentClockCount();
}
- if (now > mExpires)
+ if (now >= mExpires)
{
// mStopped from ringBell() is the value we want
mActive = false;
@@ -124,7 +132,7 @@ void LLDeadmanTimer::ringBell(U64 now)
now = LLTimer::getCurrentClockCount();
}
- if (now > mExpires)
+ if (now >= mExpires)
{
mActive = false;
mDone = true;