39 #ifndef CGU_INTRUSIVE_PTR_H
40 #define CGU_INTRUSIVE_PTR_H
51 #ifdef CGU_INTRUSIVE_LOCK_COUNTER_USE_MUTEX
103 if (obj_p) obj_p->unref();
107 if (obj_p) obj_p->ref();
132 obj_p = intr_ptr.obj_p;
141 obj_p = intr_ptr.obj_p;
158 obj_p = intr_ptr.obj_p;
170 obj_p = intr_ptr.obj_p;
220 T*
get()
const noexcept {
return obj_p;}
292 void ref() noexcept {++count;}
302 if (count == 0)
delete this;
350 #ifdef CGU_INTRUSIVE_LOCK_COUNTER_USE_MUTEX
379 #ifdef CGU_INTRUSIVE_LOCK_COUNTER_USE_MUTEX
383 g_atomic_int_inc(&count);
394 #ifdef CGU_INTRUSIVE_LOCK_COUNTER_USE_MUTEX
403 if (g_atomic_int_dec_and_test(&count)) {
430 #if defined(CGU_USE_SMART_PTR_COMPARISON) || defined(DOXYGEN_PARSING)
444 return (s1.get() == s2.get());
476 return std::less<T*>()(s1.get(), s2.get());
479 #endif // CGU_USE_SMART_PTR_COMPARISON
486 #if defined(CGU_USE_SMART_PTR_COMPARISON) && !defined(DOXYGEN_PARSING)
491 struct hash<Cgu::IntrusivePtr<T>> {
492 typedef std::size_t result_type;
494 result_type operator()(
const argument_type& s)
const {
502 #endif // CGU_USE_SMART_PTR_COMPARISON