From 155a5e4cd4614641d1aa169aaeaae8ac7234f2aa Mon Sep 17 00:00:00 2001 From: Nicky Date: Fri, 6 Apr 2018 00:11:57 +0200 Subject: [PATCH] After input from Nat: - Rename LLAtomic to LLAtomicBase - LLAtomicBase has now only one required argument, the type to wrap. The other will be deduced as std::atomic< Type > if not supplied. - I did notice the forward declaration in llapp.h was not used, so away with it. --- indra/llcommon/llapp.h | 7 ------ indra/llcommon/llapr.h | 33 ++++++++++++++-------------- indra/llcommon/llinstancetracker.cpp | 2 +- indra/llcommon/llqueuedthread.h | 2 +- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index 5b32975c78..bd0e409696 100644 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -32,13 +32,6 @@ #include "llsd.h" #include // Forward declarations -template class LLAtomic; - -#ifndef LL_LINUX -typedef LLAtomic LLAtomicU32; -#else -typedef LLAtomic LLAtomicU32; -#endif class LLErrorThread; class LLLiveFile; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 3acaa8197e..9ca47f6d66 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -174,39 +174,40 @@ protected: std::mutex* mMutex; }; -template class LLAtomic +template > class LLAtomicBase { public: - LLAtomic() {}; - LLAtomic( Type x ) { mData.store( x ); }; - ~LLAtomic() {}; + LLAtomicBase() {}; + LLAtomicBase( Type x ) { mData.store( x ); }; + ~LLAtomicBase() {}; - operator const Type() { return (Type)mData.load(); } + operator const Type() { return mData; } - Type CurrentValue() const { return (Type)mData; } + Type CurrentValue() const { return mData; } - Type operator =( Type x) { mData.store( x ); return Type(mData); } + Type operator =( Type x) { mData.store( x ); return mData; } void operator -=(Type x) { mData -= x; } void operator +=(Type x) { mData += x; } - Type operator ++(int) { return ++mData; } // Type++ - Type operator --(int) { return --mData; } // approximately --Type (0 if final is 0, non-zero otherwise) + Type operator ++(int) { return mData++; } + Type operator --(int) { return mData--; } - Type operator ++() { return mData++; } // Type++ - Type operator --() { return mData--; } // approximately --Type (0 if final is 0, non-zero otherwise) + Type operator ++() { return ++mData; } + Type operator --() { return --mData; } private: AtomicType mData; }; +// ND: Typedefs for specialized versions. Using std::atomic_(u)int32_t to get the optimzed implementation. #ifndef LL_LINUX -typedef LLAtomic LLAtomicU32; -typedef LLAtomic LLAtomicS32; +typedef LLAtomicBase LLAtomicU32; +typedef LLAtomicBase LLAtomicS32; #else -typedef LLAtomic LLAtomicU32; -typedef LLAtomic LLAtomicS32; +typedef LLAtomicBase LLAtomicU32; +typedef LLAtomicBase LLAtomicS32; #endif -typedef LLAtomic LLAtomicBool; +typedef LLAtomicBase LLAtomicBool; // File IO convenience functions. // Returns NULL if the file fails to open, sets *sizep to file size if not NULL diff --git a/indra/llcommon/llinstancetracker.cpp b/indra/llcommon/llinstancetracker.cpp index 6352cac99c..3f990f4869 100644 --- a/indra/llcommon/llinstancetracker.cpp +++ b/indra/llcommon/llinstancetracker.cpp @@ -47,5 +47,5 @@ void LLInstanceTrackerBase::StaticBase::decrementDepth() U32 LLInstanceTrackerBase::StaticBase::getDepth() { - return sIterationNestDepth.load(); + return sIterationNestDepth; } diff --git a/indra/llcommon/llqueuedthread.h b/indra/llcommon/llqueuedthread.h index e97fb36b7b..3235265e69 100644 --- a/indra/llcommon/llqueuedthread.h +++ b/indra/llcommon/llqueuedthread.h @@ -128,7 +128,7 @@ public: }; protected: - LLAtomic > mStatus; + LLAtomicBase mStatus; U32 mPriority; U32 mFlags; };