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