summaryrefslogtreecommitdiff
path: root/indra/llcommon/llthreadlocalstorage.h
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 08:55:20 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-04-24 08:55:20 -0400
commit3ae8a821c3b627f3b02df636e7649f28b97d6f57 (patch)
tree79d5d3f2b262b7f5d60cc6135b80221878aa74b8 /indra/llcommon/llthreadlocalstorage.h
parent39b17157f9c31a4b911113561d4fc8f86396c430 (diff)
parentfde0868231a25b8c9ce03a86cb53f1738d35688d (diff)
merge
Diffstat (limited to 'indra/llcommon/llthreadlocalstorage.h')
-rw-r--r--indra/llcommon/llthreadlocalstorage.h41
1 files changed, 2 insertions, 39 deletions
diff --git a/indra/llcommon/llthreadlocalstorage.h b/indra/llcommon/llthreadlocalstorage.h
index ec3b52c8cb..3b5786023f 100644
--- a/indra/llcommon/llthreadlocalstorage.h
+++ b/indra/llcommon/llthreadlocalstorage.h
@@ -130,56 +130,19 @@ class LLThreadLocalSingletonPointer
public:
LL_FORCE_INLINE static DERIVED_TYPE* getInstance()
{
-#if LL_DARWIN
- createTLSKey();
- return (DERIVED_TYPE*)pthread_getspecific(sInstanceKey);
-#else
return sInstance;
-#endif
}
static void setInstance(DERIVED_TYPE* instance)
{
-#if LL_DARWIN
- createTLSKey();
- pthread_setspecific(sInstanceKey, (void*)instance);
-#else
sInstance = instance;
-#endif
}
private:
-
-#if LL_WINDOWS
- static __declspec(thread) DERIVED_TYPE* sInstance;
-#elif LL_LINUX
- static __thread DERIVED_TYPE* sInstance;
-#elif LL_DARWIN
- static void TLSError()
- {
- LL_ERRS() << "Could not create thread local storage" << LL_ENDL;
- }
- static void createTLSKey()
- {
- static S32 key_created = pthread_key_create(&sInstanceKey, NULL);
- if (key_created != 0)
- {
- LL_ERRS() << "Could not create thread local storage" << LL_ENDL;
- }
- }
- static pthread_key_t sInstanceKey;
-#endif
+ static LL_THREAD_LOCAL DERIVED_TYPE* sInstance;
};
-#if LL_WINDOWS
-template<typename DERIVED_TYPE>
-__declspec(thread) DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;
-#elif LL_LINUX
-template<typename DERIVED_TYPE>
-__thread DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;
-#elif LL_DARWIN
template<typename DERIVED_TYPE>
-pthread_key_t LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstanceKey;
-#endif
+LL_THREAD_LOCAL DERIVED_TYPE* LLThreadLocalSingletonPointer<DERIVED_TYPE>::sInstance = NULL;
#endif // LL_LLTHREADLOCALSTORAGE_H