Loading libutils/include/utils/RefBase.h +31 −44 Original line number Diff line number Diff line Loading @@ -416,13 +416,16 @@ public: wp(std::nullptr_t) : wp() {} #else wp(T* other); // NOLINT(implicit) template <typename U> wp(U* other); // NOLINT(implicit) wp& operator=(T* other); template <typename U> wp& operator=(U* other); #endif wp(const wp<T>& other); explicit wp(const sp<T>& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> wp(U* other); // NOLINT(implicit) #endif template<typename U> wp(const sp<U>& other); // NOLINT(implicit) template<typename U> wp(const wp<U>& other); // NOLINT(implicit) Loading @@ -430,15 +433,9 @@ public: // Assignment #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) wp& operator = (T* other); #endif wp& operator = (const wp<T>& other); wp& operator = (const sp<T>& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> wp& operator = (U* other); #endif template<typename U> wp& operator = (const wp<U>& other); template<typename U> wp& operator = (const sp<U>& other); Loading Loading @@ -559,6 +556,31 @@ wp<T>::wp(T* other) { m_refs = other ? m_refs = other->createWeak(this) : nullptr; } template <typename T> template <typename U> wp<T>::wp(U* other) : m_ptr(other) { m_refs = other ? other->createWeak(this) : nullptr; } template <typename T> wp<T>& wp<T>::operator=(T* other) { weakref_type* newRefs = other ? other->createWeak(this) : nullptr; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } template <typename T> template <typename U> wp<T>& wp<T>::operator=(U* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> Loading @@ -575,15 +597,6 @@ wp<T>::wp(const sp<T>& other) m_refs = m_ptr ? m_ptr->createWeak(this) : nullptr; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> wp<T>::wp(U* other) : m_ptr(other) { m_refs = other ? other->createWeak(this) : nullptr; } #endif template<typename T> template<typename U> wp<T>::wp(const wp<U>& other) : m_ptr(other.m_ptr) Loading @@ -609,19 +622,6 @@ wp<T>::~wp() if (m_ptr) m_refs->decWeak(this); } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> wp<T>& wp<T>::operator = (T* other) { weakref_type* newRefs = other ? other->createWeak(this) : nullptr; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> wp<T>& wp<T>::operator = (const wp<T>& other) { Loading @@ -646,19 +646,6 @@ wp<T>& wp<T>::operator = (const sp<T>& other) return *this; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> wp<T>& wp<T>::operator = (U* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> template<typename U> wp<T>& wp<T>::operator = (const wp<U>& other) { Loading libutils/include/utils/StrongPointer.h +28 −35 Original line number Diff line number Diff line Loading @@ -62,13 +62,16 @@ public: sp(std::nullptr_t) : sp() {} #else sp(T* other); // NOLINT(implicit) template <typename U> sp(U* other); // NOLINT(implicit) sp& operator=(T* other); template <typename U> sp& operator=(U* other); #endif sp(const sp<T>& other); sp(sp<T>&& other) noexcept; #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> sp(U* other); // NOLINT(implicit) #endif template<typename U> sp(const sp<U>& other); // NOLINT(implicit) template<typename U> sp(sp<U>&& other); // NOLINT(implicit) Loading @@ -82,17 +85,11 @@ public: // Assignment #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) sp& operator = (T* other); #endif sp& operator = (const sp<T>& other); sp& operator=(sp<T>&& other) noexcept; template<typename U> sp& operator = (const sp<U>& other); template<typename U> sp& operator = (sp<U>&& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> sp& operator = (U* other); #endif //! Special optimization for use by ProcessState (and nobody else). void force_set(T* other); Loading Loading @@ -247,6 +244,28 @@ sp<T>::sp(T* other) other->incStrong(this); } } template <typename T> template <typename U> sp<T>::sp(U* other) : m_ptr(other) { if (other) { check_not_on_stack(other); (static_cast<T*>(other))->incStrong(this); } } template <typename T> sp<T>& sp<T>::operator=(T* other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); if (other) { check_not_on_stack(other); other->incStrong(this); } if (oldPtr) oldPtr->decStrong(this); if (oldPtr != *const_cast<T* volatile*>(&m_ptr)) sp_report_race(); m_ptr = other; return *this; } #endif template<typename T> Loading @@ -261,17 +280,6 @@ sp<T>::sp(sp<T>&& other) noexcept : m_ptr(other.m_ptr) { other.m_ptr = nullptr; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> sp<T>::sp(U* other) : m_ptr(other) { if (other) { check_not_on_stack(other); (static_cast<T*>(other))->incStrong(this); } } #endif template<typename T> template<typename U> sp<T>::sp(const sp<U>& other) : m_ptr(other.m_ptr) { Loading Loading @@ -319,21 +327,6 @@ sp<T>& sp<T>::operator=(sp<T>&& other) noexcept { return *this; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> sp<T>& sp<T>::operator =(T* other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); if (other) { check_not_on_stack(other); other->incStrong(this); } if (oldPtr) oldPtr->decStrong(this); if (oldPtr != *const_cast<T* volatile*>(&m_ptr)) sp_report_race(); m_ptr = other; return *this; } #endif template<typename T> template<typename U> sp<T>& sp<T>::operator =(const sp<U>& other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); Loading Loading
libutils/include/utils/RefBase.h +31 −44 Original line number Diff line number Diff line Loading @@ -416,13 +416,16 @@ public: wp(std::nullptr_t) : wp() {} #else wp(T* other); // NOLINT(implicit) template <typename U> wp(U* other); // NOLINT(implicit) wp& operator=(T* other); template <typename U> wp& operator=(U* other); #endif wp(const wp<T>& other); explicit wp(const sp<T>& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> wp(U* other); // NOLINT(implicit) #endif template<typename U> wp(const sp<U>& other); // NOLINT(implicit) template<typename U> wp(const wp<U>& other); // NOLINT(implicit) Loading @@ -430,15 +433,9 @@ public: // Assignment #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) wp& operator = (T* other); #endif wp& operator = (const wp<T>& other); wp& operator = (const sp<T>& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> wp& operator = (U* other); #endif template<typename U> wp& operator = (const wp<U>& other); template<typename U> wp& operator = (const sp<U>& other); Loading Loading @@ -559,6 +556,31 @@ wp<T>::wp(T* other) { m_refs = other ? m_refs = other->createWeak(this) : nullptr; } template <typename T> template <typename U> wp<T>::wp(U* other) : m_ptr(other) { m_refs = other ? other->createWeak(this) : nullptr; } template <typename T> wp<T>& wp<T>::operator=(T* other) { weakref_type* newRefs = other ? other->createWeak(this) : nullptr; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } template <typename T> template <typename U> wp<T>& wp<T>::operator=(U* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> Loading @@ -575,15 +597,6 @@ wp<T>::wp(const sp<T>& other) m_refs = m_ptr ? m_ptr->createWeak(this) : nullptr; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> wp<T>::wp(U* other) : m_ptr(other) { m_refs = other ? other->createWeak(this) : nullptr; } #endif template<typename T> template<typename U> wp<T>::wp(const wp<U>& other) : m_ptr(other.m_ptr) Loading @@ -609,19 +622,6 @@ wp<T>::~wp() if (m_ptr) m_refs->decWeak(this); } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> wp<T>& wp<T>::operator = (T* other) { weakref_type* newRefs = other ? other->createWeak(this) : nullptr; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> wp<T>& wp<T>::operator = (const wp<T>& other) { Loading @@ -646,19 +646,6 @@ wp<T>& wp<T>::operator = (const sp<T>& other) return *this; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> wp<T>& wp<T>::operator = (U* other) { weakref_type* newRefs = other ? other->createWeak(this) : 0; if (m_ptr) m_refs->decWeak(this); m_ptr = other; m_refs = newRefs; return *this; } #endif template<typename T> template<typename U> wp<T>& wp<T>::operator = (const wp<U>& other) { Loading
libutils/include/utils/StrongPointer.h +28 −35 Original line number Diff line number Diff line Loading @@ -62,13 +62,16 @@ public: sp(std::nullptr_t) : sp() {} #else sp(T* other); // NOLINT(implicit) template <typename U> sp(U* other); // NOLINT(implicit) sp& operator=(T* other); template <typename U> sp& operator=(U* other); #endif sp(const sp<T>& other); sp(sp<T>&& other) noexcept; #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> sp(U* other); // NOLINT(implicit) #endif template<typename U> sp(const sp<U>& other); // NOLINT(implicit) template<typename U> sp(sp<U>&& other); // NOLINT(implicit) Loading @@ -82,17 +85,11 @@ public: // Assignment #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) sp& operator = (T* other); #endif sp& operator = (const sp<T>& other); sp& operator=(sp<T>&& other) noexcept; template<typename U> sp& operator = (const sp<U>& other); template<typename U> sp& operator = (sp<U>&& other); #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename U> sp& operator = (U* other); #endif //! Special optimization for use by ProcessState (and nobody else). void force_set(T* other); Loading Loading @@ -247,6 +244,28 @@ sp<T>::sp(T* other) other->incStrong(this); } } template <typename T> template <typename U> sp<T>::sp(U* other) : m_ptr(other) { if (other) { check_not_on_stack(other); (static_cast<T*>(other))->incStrong(this); } } template <typename T> sp<T>& sp<T>::operator=(T* other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); if (other) { check_not_on_stack(other); other->incStrong(this); } if (oldPtr) oldPtr->decStrong(this); if (oldPtr != *const_cast<T* volatile*>(&m_ptr)) sp_report_race(); m_ptr = other; return *this; } #endif template<typename T> Loading @@ -261,17 +280,6 @@ sp<T>::sp(sp<T>&& other) noexcept : m_ptr(other.m_ptr) { other.m_ptr = nullptr; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> template<typename U> sp<T>::sp(U* other) : m_ptr(other) { if (other) { check_not_on_stack(other); (static_cast<T*>(other))->incStrong(this); } } #endif template<typename T> template<typename U> sp<T>::sp(const sp<U>& other) : m_ptr(other.m_ptr) { Loading Loading @@ -319,21 +327,6 @@ sp<T>& sp<T>::operator=(sp<T>&& other) noexcept { return *this; } #if !defined(ANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION) template<typename T> sp<T>& sp<T>::operator =(T* other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); if (other) { check_not_on_stack(other); other->incStrong(this); } if (oldPtr) oldPtr->decStrong(this); if (oldPtr != *const_cast<T* volatile*>(&m_ptr)) sp_report_race(); m_ptr = other; return *this; } #endif template<typename T> template<typename U> sp<T>& sp<T>::operator =(const sp<U>& other) { T* oldPtr(*const_cast<T* volatile*>(&m_ptr)); Loading