summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/CMakeLists.txt1
-rw-r--r--indra/llcommon/llcallbacklist.cpp27
-rwxr-xr-xindra/llcommon/tempset.h41
3 files changed, 43 insertions, 26 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index d5440d6bc8..20670d7ebe 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -259,6 +259,7 @@ set(llcommon_HEADER_FILES
lualistener.h
stdtypes.h
stringize.h
+ tempset.h
threadpool.h
threadpool_fwd.h
threadsafeschedule.h
diff --git a/indra/llcommon/llcallbacklist.cpp b/indra/llcommon/llcallbacklist.cpp
index 015475a903..555c793333 100644
--- a/indra/llcommon/llcallbacklist.cpp
+++ b/indra/llcommon/llcallbacklist.cpp
@@ -29,6 +29,7 @@
#include "llerror.h"
#include "llexception.h"
#include "llsdutil.h"
+#include "tempset.h"
#include <boost/container_hash/hash.hpp>
#include <iomanip>
#include <vector>
@@ -292,32 +293,6 @@ void Timers::setTimeslice(F32 timeslice)
}
}
-// RAII class to set specified variable to specified value
-// only for the duration of containing scope
-template <typename VAR, typename VALUE>
-class TempSet
-{
-public:
- TempSet(VAR& var, const VALUE& value):
- mVar(var),
- mOldValue(mVar)
- {
- mVar = value;
- }
-
- TempSet(const TempSet&) = delete;
- TempSet& operator=(const TempSet&) = delete;
-
- ~TempSet()
- {
- mVar = mOldValue;
- }
-
-private:
- VAR& mVar;
- VALUE mOldValue;
-};
-
bool Timers::tick()
{
// Fetch current time only on entry, even though running some mQueue task
diff --git a/indra/llcommon/tempset.h b/indra/llcommon/tempset.h
new file mode 100755
index 0000000000..e1496bd5fc
--- /dev/null
+++ b/indra/llcommon/tempset.h
@@ -0,0 +1,41 @@
+/**
+ * @file tempset.h
+ * @author Nat Goodspeed
+ * @date 2024-06-12
+ * @brief Temporarily override a variable for scope duration, then restore
+ *
+ * $LicenseInfo:firstyear=2024&license=viewerlgpl$
+ * Copyright (c) 2024, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+#if ! defined(LL_TEMPSET_H)
+#define LL_TEMPSET_H
+
+// RAII class to set specified variable to specified value
+// only for the duration of containing scope
+template <typename VAR, typename VALUE>
+class TempSet
+{
+public:
+ TempSet(VAR& var, const VALUE& value):
+ mVar(var),
+ mOldValue(mVar)
+ {
+ mVar = value;
+ }
+
+ TempSet(const TempSet&) = delete;
+ TempSet& operator=(const TempSet&) = delete;
+
+ ~TempSet()
+ {
+ mVar = mOldValue;
+ }
+
+private:
+ VAR& mVar;
+ VALUE mOldValue;
+};
+
+#endif /* ! defined(LL_TEMPSET_H) */