#include <Refcounted_Auto_Ptr.h>
Collaboration diagram for ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >:
Private Member Functions | |
X * | release (void) |
Sets the pointer value to 0 and returns its old value. | |
void | reset (X *p=0) |
X * | get (void) const |
Get the pointer value. | |
int | count (void) const |
Get the reference count value. | |
int | null (void) const |
Allows us to check for NULL on all ACE_Refcounted_Auto_Ptr objects. | |
ACE_Refcounted_Auto_Ptr_Rep (X *p=0) | |
~ACE_Refcounted_Auto_Ptr_Rep (void) | |
Static Private Member Functions | |
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | internal_create (X *p) |
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | create (X *p) |
ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | attach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep) |
void | detach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep) |
void | assign (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep, ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *new_rep) |
Private Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
ACE_Auto_Basic_Ptr< X > | ptr_ |
Pointer to the result. | |
int | ref_count_ |
Reference count. | |
ACE_LOCK | lock_ |
Synchronization variable for the MT_SAFE . | |
Friends | |
class | ACE_Refcounted_Auto_Ptr< X, ACE_LOCK > |
Definition at line 121 of file Refcounted_Auto_Ptr.h.
|
Definition at line 115 of file Refcounted_Auto_Ptr.inl.
00116 : ptr_ (p), 00117 ref_count_ (0) 00118 { 00119 } |
|
Definition at line 122 of file Refcounted_Auto_Ptr.inl.
00123 { 00124 } |
|
Decreases the rep's reference count and and deletes rep if there are no more references to rep. Then assigns new_rep to rep. Precondition (rep != 0 && new_rep != 0) Definition at line 93 of file Refcounted_Auto_Ptr.inl. References ACE_ASSERT, ACE_GUARD, ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::lock_, and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_.
00095 { 00096 ACE_ASSERT (rep != 0); 00097 ACE_ASSERT (new_rep != 0); 00098 00099 ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *old = 0; 00100 { 00101 // detached old last for exception safety 00102 ACE_GUARD (ACE_LOCK, guard, rep->lock_); 00103 old = rep; 00104 rep = new_rep; 00105 00106 if (old->ref_count_-- > 0) 00107 return; 00108 00109 } // The lock is released before deleting old rep object below. 00110 00111 delete old; 00112 } |
|
Increase the reference count and return argument. Uses the attribute "ace_lock_" to synchronize reference count updating. Precondition (rep != 0). Definition at line 62 of file Refcounted_Auto_Ptr.inl. References ACE_ASSERT, ACE_GUARD_RETURN, ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::lock_, and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_.
00063 { 00064 ACE_ASSERT (rep != 0); 00065 00066 ACE_GUARD_RETURN (ACE_LOCK, guard, rep->lock_, rep); 00067 00068 ++rep->ref_count_; 00069 00070 return rep; 00071 } |
|
Get the reference count value.
Definition at line 11 of file Refcounted_Auto_Ptr.inl. References ACE_GUARD_RETURN. Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::count().
00012 { 00013 ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); 00014 return this->ref_count_; 00015 } |
|
Create a ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> and initialize the reference count. Definition at line 48 of file Refcounted_Auto_Ptr.inl. References ACE_ASSERT, ACE_throw_bad_alloc, and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::internal_create().
00049 { 00050 // Yes set ref count to zero. 00051 ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = internal_create (p); 00052 #if defined (ACE_NEW_THROWS_EXCEPTIONS) 00053 if (temp == 0) 00054 ACE_throw_bad_alloc; 00055 #else 00056 ACE_ASSERT (temp != 0); 00057 #endif /* ACE_NEW_THROWS_EXCEPTIONS */ 00058 return temp; 00059 } |
|
Decreases the reference count and and deletes rep if there are no more references to rep. Precondition (rep != 0) Definition at line 74 of file Refcounted_Auto_Ptr.inl. References ACE_ASSERT, ACE_GUARD, ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::lock_, and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::ref_count_.
00075 { 00076 ACE_ASSERT (rep != 0); 00077 ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *rep_del = 0; 00078 00079 { 00080 ACE_GUARD (ACE_LOCK, guard, rep->lock_); 00081 00082 if (rep->ref_count_-- == 0) 00083 // Since rep contains the lock held by the ACE_Guard, the guard 00084 // needs to be released before freeing the memory holding the 00085 // lock. So save the pointer to free, then release, then free. 00086 rep_del = rep; 00087 } // Release the lock 00088 if (0 != rep_del) 00089 delete rep; 00090 } |
|
Get the pointer value.
Definition at line 143 of file Refcounted_Auto_Ptr.inl. References ACE_GUARD_RETURN. Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::get(), ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator *(), and ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::operator->().
00144 { 00145 ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); 00146 00147 return this->ptr_.get (); 00148 } |
|
Allocate a new ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> instance, returning NULL if it cannot be created. Definition at line 38 of file Refcounted_Auto_Ptr.inl. References ACE_NEW_RETURN. Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::create().
00039 { 00040 ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> *temp = 0; 00041 ACE_NEW_RETURN (temp, 00042 (ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK>) (p), 00043 0); 00044 return temp; 00045 } |
|
Allows us to check for NULL on all ACE_Refcounted_Auto_Ptr objects.
Definition at line 24 of file Refcounted_Auto_Ptr.inl. References ACE_GUARD_RETURN. Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::null().
00025 { 00026 ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); 00027 00028 return this->ptr_.get () == 0; 00029 } |
|
Sets the pointer value to 0 and returns its old value.
Definition at line 127 of file Refcounted_Auto_Ptr.inl. References ACE_GUARD_RETURN. Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::release().
00128 { 00129 ACE_GUARD_RETURN (ACE_LOCK, guard, this->lock_, 0); 00130 00131 return this->ptr_.release (); 00132 } |
|
Invokes delete on the previous pointer value and then sets the pointer value to the specified value. Definition at line 135 of file Refcounted_Auto_Ptr.inl. References ACE_GUARD. Referenced by ACE_Refcounted_Auto_Ptr< X, ACE_LOCK >::reset().
|
|
Definition at line 124 of file Refcounted_Auto_Ptr.h. |
|
Declare the dynamic allocation hooks.
Definition at line 140 of file Refcounted_Auto_Ptr.h. |
|
Synchronization variable for the MT_SAFE .
Definition at line 182 of file Refcounted_Auto_Ptr.h. Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::assign(), ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::attach(), and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::detach(). |
|
Pointer to the result.
Definition at line 174 of file Refcounted_Auto_Ptr.h. |
|
Reference count.
Definition at line 177 of file Refcounted_Auto_Ptr.h. Referenced by ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::assign(), ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::attach(), and ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK >::detach(). |