12 #ifndef __UT_INTRUSIVEPTR_H_INCLUDED__
13 #define __UT_INTRUSIVEPTR_H_INCLUDED__
19 #include <hboost/intrusive_ptr.hpp>
91 hboost::intrusive_ptr<T>::operator=(that);
99 hboost::intrusive_ptr<T>::operator=(that);
106 hboost::intrusive_ptr<T>::operator=(std::move(that));
110 template <
typename Y>
114 hboost::intrusive_ptr<T>::operator=(std::move(that));
120 template <
typename T,
typename... ArgsT>
190 return (
counter -= refs_to_remove);
197 typename Deleter = std::default_delete<DerivedT>,
202 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
206 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
210 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
213 typename CounterPolicyT::pod_type refs_to_add) noexcept;
215 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
218 typename CounterPolicyT::pod_type refs_to_remove) noexcept;
239 typename CounterPolicyT
265 return CounterPolicyT::load(myRefCount);
278 friend void intrusive_ptr_add_ref<DerivedT,Deleter,CounterPolicyT>(
281 friend void intrusive_ptr_release<DerivedT,Deleter,CounterPolicyT>(
284 friend void intrusive_ptr_add_ref<DerivedT,Deleter,CounterPolicyT>(
286 typename CounterPolicyT::pod_type refs_to_add) noexcept;
287 friend void intrusive_ptr_release<DerivedT,Deleter,CounterPolicyT>(
289 typename CounterPolicyT::pod_type refs_to_remove) noexcept;
293 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
298 CounterPolicyT::increment(
p->myRefCount);
300 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
305 if (CounterPolicyT::decrement(
p->myRefCount) == 0)
312 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
316 typename CounterPolicyT::pod_type refs_to_add) noexcept
318 CounterPolicyT::increment(
p->myRefCount, refs_to_add);
320 template <
typename DerivedT,
typename Deleter,
typename CounterPolicyT>
324 typename CounterPolicyT::pod_type refs_to_remove) noexcept
326 if (CounterPolicyT::decrement(
p->myRefCount, refs_to_remove) == 0)
336 template <
typename T>
337 struct DefaultClearer;
339 template <
typename T>
345 {
return v.get() ==
nullptr; }
348 static const bool clearNeedsDestruction =
false;
352 #endif // __UT_INTRUSIVEPTR_H_INCLUDED__
SYS_FORCE_INLINE UT_IntrusivePtr(T *p, bool add_ref)
static SYS_FORCE_INLINE void increment(type &counter, pod_type refs_to_add) noexcept
static SYS_FORCE_INLINE void increment(type &counter, pod_type refs_to_add) noexcept
SYS_FORCE_INLINE UT_IntrusivePtr() noexcept
void intrusive_ptr_release(const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *p) noexcept
static SYS_FORCE_INLINE void increment(type &counter) noexcept
UT_IntrusivePtr< T > UTmakeIntrusive(ArgsT &&...args)
Constructs an object of type T wrapped in a UT_IntrusivePtr.
SYS_FORCE_INLINE UT_IntrusivePtr(T *p)
SYS_FORCE_INLINE T * SYSconst_cast(const T *foo)
SYS_AtomicInt< int32 > SYS_AtomicInt32
SYS_FORCE_INLINE UT_IntrusivePtr(const UT_IntrusivePtr< Y > &p)
A reference counter base class for use with UT_IntrusivePtr.
void intrusive_ptr_add_ref(const UT_IntrusiveRefCounter< DerivedT, Deleter, CounterPolicyT > *p) noexcept
NON Thread-safe policy for UT_IntrusiveRefCounter.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
static bool isClear(const UT_IntrusivePtr< T > &v)
SYS_FORCE_INLINE uint32 use_count() const noexcept
Return current counter.
SYS_FORCE_INLINE UT_IntrusivePtr< T > & operator=(UT_IntrusivePtr< T > &&that)
SYS_FORCE_INLINE UT_IntrusivePtr< T > & operator=(const UT_IntrusivePtr< T > &that)
Wrapper around hboost::intrusive_ptr.
SYS_FORCE_INLINE UT_IntrusivePtr(const UT_IntrusivePtr< T > &p)
SYS_FORCE_INLINE UT_IntrusiveRefCounter(const UT_IntrusiveRefCounter &) noexcept
Copy constructor: Sets counter to 0.
SYS_FORCE_INLINE UT_IntrusivePtr< T > & operator=(UT_IntrusivePtr< Y > &&that)
static void clearConstruct(UT_IntrusivePtr< T > *p)
static SYS_FORCE_INLINE uint32 decrement(type &counter, pod_type refs_to_remove) noexcept
static void clear(UT_IntrusivePtr< T > &v)
SYS_FORCE_INLINE UT_IntrusivePtr(UT_IntrusivePtr< T > &&p)
static SYS_FORCE_INLINE uint32 decrement(type &counter, pod_type refs_to_remove) noexcept
static SYS_FORCE_INLINE uint32 decrement(type &counter) noexcept
static SYS_FORCE_INLINE uint32 load(const type &counter) noexcept
SYS_FORCE_INLINE ~UT_IntrusiveRefCounter()
Destructor: Only derived classes can destruct this.
SYS_FORCE_INLINE UT_IntrusivePtr< T > & operator=(const UT_IntrusivePtr< Y > &that)
SYS_FORCE_INLINE UT_IntrusiveRefCounter() noexcept
Default constructor: Sets counter to 0.
static SYS_FORCE_INLINE uint32 decrement(type &counter) noexcept
SYS_FORCE_INLINE UT_IntrusivePtr(UT_IntrusivePtr< Y > &&p)
static SYS_FORCE_INLINE uint32 load(const type &counter) noexcept
Thread-safe policy for UT_IntrusiveRefCounter.
static SYS_FORCE_INLINE void increment(type &counter) noexcept
A simple intrusive pointer, modeled after std::shared_ptr.