Go to the documentation of this file.
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
void ref() noexcept
Definition: intrusive_ptr.h:378
Definition: application.h:44
T & operator*() const noexcept
Definition: intrusive_ptr.h:226
int lock() noexcept
Definition: mutex.h:147
IntrusiveCounter & operator=(const IntrusiveCounter &)=delete
virtual ~IntrusiveLockCounter()
Definition: intrusive_ptr.h:427
int unlock() noexcept
Definition: mutex.h:170
This is a counter class providing the ref() and unref() functions required by IntrusivePtr.
Definition: intrusive_ptr.h:268
IntrusiveCounter(const IntrusiveCounter &)=delete
IntrusiveLockCounter(const IntrusiveLockCounter &)=delete
This is a smart pointer for managing objects allocated on freestore which maintain their own referenc...
Definition: intrusive_ptr.h:98
void unref()
Definition: intrusive_ptr.h:393
IntrusivePtr & operator=(IntrusivePtr< U > &&intr_ptr)
Definition: intrusive_ptr.h:211
IntrusivePtr(IntrusivePtr< U > &&intr_ptr) noexcept
Definition: intrusive_ptr.h:169
bool operator<(const GobjHandle< T > &h1, const GobjHandle< T > &h2)
Definition: gobj_handle.h:632
bool operator!=(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:613
void swap(Cgu::AsyncQueue< T, Container > &q1, Cgu::AsyncQueue< T, Container > &q2)
Definition: async_queue.h:1493
IntrusivePtr(T *ptr=0)
Definition: intrusive_ptr.h:119
IntrusivePtr(const IntrusivePtr &intr_ptr)
Definition: intrusive_ptr.h:131
void ref() noexcept
Definition: intrusive_ptr.h:292
T * operator->() const noexcept
Definition: intrusive_ptr.h:233
IntrusivePtr & operator=(IntrusivePtr intr_ptr)
Definition: intrusive_ptr.h:184
IntrusivePtr(const IntrusivePtr< U > &intr_ptr)
Definition: intrusive_ptr.h:157
bool operator==(const GobjHandle< T > &h1, const GobjHandle< T > &h2) noexcept
Definition: gobj_handle.h:600
IntrusivePtr & operator=(const IntrusivePtr< U > &intr_ptr)
Definition: intrusive_ptr.h:198
A scoped locking class for exception safe Mutex locking.
Definition: mutex.h:207
T * get() const noexcept
Definition: intrusive_ptr.h:220
friend class IntrusivePtr
Definition: intrusive_ptr.h:145
A specialization of std::hash for Cgu::Callback::FunctorArg, Cgu::Callback::SafeFunctorArg,...
virtual ~IntrusiveCounter()
Definition: intrusive_ptr.h:314
This is a counter class providing the ref() and unref() functions required by IntrusivePtr,...
Definition: intrusive_ptr.h:349
IntrusivePtr(IntrusivePtr &&intr_ptr) noexcept
Definition: intrusive_ptr.h:140
Provides wrapper classes for pthread mutexes and condition variables, and scoped locking classes for ...
void unref()
Definition: intrusive_ptr.h:300
IntrusiveCounter() noexcept
Definition: intrusive_ptr.h:308
IntrusiveLockCounter & operator=(const IntrusiveLockCounter &)=delete
~IntrusivePtr()
Definition: intrusive_ptr.h:253
A wrapper class for pthread mutexes.
Definition: mutex.h:117
IntrusiveLockCounter()
Definition: intrusive_ptr.h:421
void reset(T *ptr=0)
Definition: intrusive_ptr.h:244