From 26fae750ba753f32f58bd56d297f2d98c5759e50 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 14 Jan 2019 22:04:44 +0200 Subject: SL-10291 Replace apr_mutex with standard C++11 functionality --- indra/llcommon/llapr.h | 57 +++++++++++--------------------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) (limited to 'indra/llcommon/llapr.h') diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 1ac5c4e9b2..73d1d180ef 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -36,15 +36,23 @@ #include #include "llwin32headerslean.h" #include "apr_thread_proc.h" -#include "apr_thread_mutex.h" #include "apr_getopt.h" #include "apr_signal.h" #include "apr_atomic.h" #include "llstring.h" -extern LL_COMMON_API apr_thread_mutex_t* gLogMutexp; -extern apr_thread_mutex_t* gCallStacksLogMutexp; +#if LL_WINDOWS +#pragma warning (push) +#pragma warning (disable:4265) +#endif +// warning C4265: 'std::_Pad' : class has virtual functions, but destructor is not virtual + +#include + +#if LL_WINDOWS +#pragma warning (pop) +#endif struct apr_dso_handle_t; /** @@ -120,50 +128,9 @@ private: S32 mNumActiveRef ; //number of active pointers pointing to the apr_pool. S32 mNumTotalRef ; //number of total pointers pointing to the apr_pool since last creating. - apr_thread_mutex_t *mMutexp; - apr_pool_t *mMutexPool; + std::unique_ptr mMutexp; } ; -/** - * @class LLScopedLock - * @brief Small class to help lock and unlock mutexes. - * - * This class is used to have a stack level lock once you already have - * an apr mutex handy. The constructor handles the lock, and the - * destructor handles the unlock. Instances of this class are - * not thread safe. - */ -class LL_COMMON_API LLScopedLock : private boost::noncopyable -{ -public: - /** - * @brief Constructor which accepts a mutex, and locks it. - * - * @param mutex An allocated APR mutex. If you pass in NULL, - * this wrapper will not lock. - */ - LLScopedLock(apr_thread_mutex_t* mutex); - - /** - * @brief Destructor which unlocks the mutex if still locked. - */ - ~LLScopedLock(); - - /** - * @brief Check lock. - */ - bool isLocked() const { return mLocked; } - - /** - * @brief This method unlocks the mutex. - */ - void unlock(); - -protected: - bool mLocked; - apr_thread_mutex_t* mMutex; -}; - template class LLAtomic32 { public: -- cgit v1.2.3 From fa15830e02ed249186625e845e2ac19749d10193 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Tue, 15 Jan 2019 18:31:17 +0200 Subject: SL-10291 Replace apr_atomic with standard C++11 functionality --- indra/llcommon/llapr.h | 28 ---------------------------- 1 file changed, 28 deletions(-) (limited to 'indra/llcommon/llapr.h') diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 73d1d180ef..da50dda103 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -38,7 +38,6 @@ #include "apr_thread_proc.h" #include "apr_getopt.h" #include "apr_signal.h" -#include "apr_atomic.h" #include "llstring.h" @@ -131,33 +130,6 @@ private: std::unique_ptr mMutexp; } ; -template class LLAtomic32 -{ -public: - LLAtomic32() {}; - LLAtomic32(Type x) {apr_atomic_set32(&mData, apr_uint32_t(x)); }; - ~LLAtomic32() {}; - - operator const Type() { apr_uint32_t data = apr_atomic_read32(&mData); return Type(data); } - - Type CurrentValue() const { apr_uint32_t data = apr_atomic_read32(const_cast< volatile apr_uint32_t* >(&mData)); return Type(data); } - - Type operator =(const Type& x) { apr_atomic_set32(&mData, apr_uint32_t(x)); return Type(mData); } - void operator -=(Type x) { apr_atomic_sub32(&mData, apr_uint32_t(x)); } - void operator +=(Type x) { apr_atomic_add32(&mData, apr_uint32_t(x)); } - Type operator ++(int) { return apr_atomic_inc32(&mData); } // Type++ - Type operator --(int) { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) - - Type operator ++() { return apr_atomic_inc32(&mData); } // Type++ - Type operator --() { return apr_atomic_dec32(&mData); } // approximately --Type (0 if final is 0, non-zero otherwise) - -private: - volatile apr_uint32_t mData; -}; - -typedef LLAtomic32 LLAtomicU32; -typedef LLAtomic32 LLAtomicS32; - // File IO convenience functions. // Returns NULL if the file fails to open, sets *sizep to file size if not NULL // abbreviated flags -- cgit v1.2.3