summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llcallbacklist.cpp22
-rw-r--r--indra/llcommon/llcallbacklist.h10
2 files changed, 30 insertions, 2 deletions
diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp
index bf7a555140..015475a903 100644
--- a/indra/llcommon/llcallbacklist.cpp
+++ b/indra/llcommon/llcallbacklist.cpp
@@ -26,9 +26,11 @@
#include "lazyeventapi.h"
#include "llcallbacklist.h"
+#include "llerror.h"
#include "llexception.h"
#include "llsdutil.h"
#include <boost/container_hash/hash.hpp>
+#include <iomanip>
#include <vector>
//
@@ -272,6 +274,24 @@ bool Timers::cancel(const handle_t& timer)
return true;
}
+void Timers::setTimeslice(F32 timeslice)
+{
+ if (timeslice < MINIMUM_TIMESLICE)
+ {
+ // use stringize() so setprecision() affects only the temporary
+ // ostream, not the common logging ostream
+ LL_WARNS("Timers") << "LL::Timers::setTimeslice("
+ << stringize(std::setprecision(4), timeslice)
+ << ") less than "
+ << stringize(std::setprecision(4), MINIMUM_TIMESLICE)
+ << ", ignoring" << LL_ENDL;
+ }
+ else
+ {
+ mTimeslice = timeslice;
+ }
+}
+
// RAII class to set specified variable to specified value
// only for the duration of containing scope
template <typename VAR, typename VALUE>
@@ -305,7 +325,7 @@ bool Timers::tick()
// sharing this thread with everything else, and there's a risk we might
// starve it if we have a sequence of tasks that take nontrivial time.
auto now{ LLDate::now().secondsSinceEpoch() };
- auto cutoff{ now + TIMESLICE };
+ auto cutoff{ now + mTimeslice };
// Capture tasks we've processed but that want to be rescheduled.
// Defer rescheduling them immediately to avoid getting stuck looping over
diff --git a/indra/llcommon/llcallbacklist.h b/indra/llcommon/llcallbacklist.h
index b245b3db94..fb4696188a 100644
--- a/indra/llcommon/llcallbacklist.h
+++ b/indra/llcommon/llcallbacklist.h
@@ -147,7 +147,11 @@ class Timers: public LLSingleton<Timers>
public:
// If tasks that come ready during a given tick() take longer than this,
// defer any subsequent ready tasks to a future tick() call.
- static constexpr F32 TIMESLICE{ 0.005f };
+ static constexpr F32 DEFAULT_TIMESLICE{ 0.005f };
+ // Setting timeslice to be less than MINIMUM_TIMESLICE could lock up
+ // Timers processing, causing it to believe it's exceeded the allowable
+ // time every tick before processing ANY queue items.
+ static constexpr F32 MINIMUM_TIMESLICE{ 0.001f };
class handle_t
{
@@ -182,6 +186,9 @@ public:
// cancel again.
bool cancel(handle_t& timer);
+ F32 getTimeslice() const { return mTimeslice; }
+ void setTimeslice(F32 timeslice);
+
// Store a handle_t returned by scheduleAt(), scheduleAfter() or
// scheduleEvery() in a temp_handle_t to cancel() automatically on
// destruction of the temp_handle_t.
@@ -278,6 +285,7 @@ private:
token_t mToken{ 0 };
// While mQueue is non-empty, register for regular callbacks.
LLCallbackList::temp_handle_t mLive;
+ F32 mTimeslice{ DEFAULT_TIMESLICE };
};
} // namespace LL