summaryrefslogtreecommitdiff
path: root/indra/llcommon/llthreadlocalstorage.h
diff options
context:
space:
mode:
authorMnikolenko Productengine <mnikolenko@productengine.com>2023-01-23 16:29:38 +0200
committerMnikolenko Productengine <mnikolenko@productengine.com>2023-01-23 16:29:56 +0200
commit111fc04e5df60e1d509b9ec80a1340bab4383cce (patch)
treeaed67acff4dd7497cf39e3a5c3632cacd57126c9 /indra/llcommon/llthreadlocalstorage.h
parent819eec6f8c3abbf71ec3bdaaf4891068574fdc46 (diff)
parenta0c3d69c620a92d73a1008f218680fb4d0ef9255 (diff)
Merge branch 'main' into DRTVWR-567
Diffstat (limited to 'indra/llcommon/llthreadlocalstorage.h')
-rw-r--r--indra/llcommon/llthreadlocalstorage.h98
1 files changed, 2 insertions, 96 deletions
diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h
index 3b5786023f..bdd28ec865 100644
--- a/indra/llcommon/llthreadlocalstorage.h
+++ b/indra/llcommon/llthreadlocalstorage.h
@@ -30,100 +30,6 @@
#include "llinstancetracker.h"
-class LLThreadLocalPointerBase : public LLInstanceTracker<LLThreadLocalPointerBase>
-{
-public:
- LLThreadLocalPointerBase()
- : mThreadKey(NULL)
- {
- if (sInitialized)
- {
- initStorage();
- }
- }
-
- LLThreadLocalPointerBase( const LLThreadLocalPointerBase& other)
- : mThreadKey(NULL)
- {
- if (sInitialized)
- {
- initStorage();
- }
- }
-
- ~LLThreadLocalPointerBase()
- {
- destroyStorage();
- }
-
- static void initAllThreadLocalStorage();
- static void destroyAllThreadLocalStorage();
-
-protected:
- void set(void* value);
-
- void* get() const;
-
- void initStorage();
- void destroyStorage();
-
-protected:
- struct apr_threadkey_t* mThreadKey;
- static bool sInitialized;
-};
-
-template <typename T>
-class LLThreadLocalPointer : public LLThreadLocalPointerBase
-{
-public:
-
- LLThreadLocalPointer()
- {}
-
- explicit LLThreadLocalPointer(T* value)
- {
- set(value);
- }
-
-
- LLThreadLocalPointer(const LLThreadLocalPointer<T>& other)
- : LLThreadLocalPointerBase(other)
- {
- set(other.get());
- }
-
- LL_FORCE_INLINE T* get() const
- {
- return (T*)LLThreadLocalPointerBase::get();
- }
-
- T* operator -> () const
- {
- return (T*)get();
- }
-
- T& operator*() const
- {
- return *(T*)get();
- }
-
- LLThreadLocalPointer<T>& operator = (T* value)
- {
- set((void*)value);
- return *this;
- }
-
- bool operator ==(const T* other) const
- {
- if (!sInitialized) return false;
- return get() == other;
- }
-
- bool isNull() const { return !sInitialized || get() == NULL; }
-
- bool notNull() const { return sInitialized && get() != NULL; }
-};
-
template<typename DERIVED_TYPE>
class LLThreadLocalSingletonPointer
{
@@ -139,10 +45,10 @@ public:
}
private:
- static LL_THREAD_LOCAL DERIVED_TYPE* sInstance;
+ static thread_local DERIVED_TYPE* sInstance;
};
template<typename DERIVED_TYPE>
-LL_THREAD_LOCAL DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;
+thread_local DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;
#endif // LL_LLTHREADLOCALSTORAGE_H