#include <Refcounted_Auto_Ptr.h>
Collaboration diagram for ACE_Refcounted_Auto_Ptr_Rep:

Private Methods | |
| X * | release (void) |
| Sets the pointer value to 0 and returns its old value. More... | |
| void | reset (X *p=0) |
| Invokes delete on the previous pointer value and then sets the pointer value to the specified value. More... | |
| X * | get (void) const |
| Get the pointer value. More... | |
| int | count (void) const |
| Get the reference count value. More... | |
| int | null (void) const |
| Allows us to check for NULL on all ACE_Refcounted_Auto_Ptr objects. More... | |
| ACE_Refcounted_Auto_Ptr_Rep (X *p=0) | |
| ~ACE_Refcounted_Auto_Ptr_Rep (void) | |
Static Private Methods | |
| ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | internal_create (X *p) |
| Allocate a new ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> instance, returning NULL if it cannot be created. More... | |
| ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | create (X *p) |
| Create a ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> and initialize the reference count. More... | |
| ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > * | attach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep) |
| Increase the reference count and return argument. Uses the attribute "ace_lock_" to synchronize reference count updating. Precondition (rep != 0). More... | |
| void | detach (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep) |
| Decreases the reference count and and deletes rep if there are no more references to rep. Precondition (rep != 0). More... | |
| void | assign (ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *&rep, ACE_Refcounted_Auto_Ptr_Rep< X, ACE_LOCK > *new_rep) |
| 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). More... | |
Private Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. More... | |
| ACE_Auto_Basic_Ptr< X > | ptr_ |
| Pointer to the result. More... | |
| int | ref_count_ |
| Reference count. More... | |
| ACE_LOCK | lock_ |
| Synchronization variable for the MT_SAFE <ACE_Hash_Map_Manager_Ex>. More... | |
Friends | |
| class | ACE_Refcounted_Auto_Ptr< X, ACE_LOCK > |
Definition at line 117 of file Refcounted_Auto_Ptr.h.
|
||||||||||
|
Definition at line 115 of file Refcounted_Auto_Ptr.i.
00116 : ptr_ (p), 00117 ref_count_ (0) 00118 { 00119 } |
|
||||||||||
|
Definition at line 122 of file Refcounted_Auto_Ptr.i.
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.i. References ACE_ASSERT, ACE_GUARD, lock_, and 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.i. References ACE_ASSERT, ACE_GUARD_RETURN, lock_, and 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 10 of file Refcounted_Auto_Ptr.i. References ACE_GUARD_RETURN, and ref_count_. Referenced by ACE_Refcounted_Auto_Ptr::count.
00011 {
00012 ACE_GUARD_RETURN (ACE_LOCK, guard, ACE_const_cast (ACE_LOCK &, this->lock_), 0);
00013 return this->ref_count_;
00014 }
|
|
||||||||||
|
Create a ACE_Refcounted_Auto_Ptr_Rep<X, ACE_LOCK> and initialize the reference count.
Definition at line 48 of file Refcounted_Auto_Ptr.i. References ACE_ASSERT, ACE_throw_bad_alloc, and 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.i. References ACE_ASSERT, ACE_GUARD, lock_, and 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.i. References ACE_GUARD_RETURN, and ptr_. Referenced by ACE_Refcounted_Auto_Ptr::get, ACE_Refcounted_Auto_Ptr::operator *, and ACE_Refcounted_Auto_Ptr::operator->.
00144 {
00145 ACE_GUARD_RETURN (ACE_LOCK, guard, ACE_const_cast (ACE_LOCK &, 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.i. References ACE_NEW_RETURN. Referenced by 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 23 of file Refcounted_Auto_Ptr.i. References ACE_GUARD_RETURN, and ptr_. Referenced by ACE_Refcounted_Auto_Ptr::null.
00024 {
00025 ACE_GUARD_RETURN (ACE_LOCK, guard,
00026 ACE_const_cast (ACE_LOCK&, 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.i. References ACE_GUARD_RETURN, and ptr_. Referenced by ACE_Refcounted_Auto_Ptr::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.i. References ACE_GUARD, and ptr_. Referenced by ACE_Refcounted_Auto_Ptr::reset.
|
|
|||||
|
Definition at line 120 of file Refcounted_Auto_Ptr.h. |
|
|||||
|
Declare the dynamic allocation hooks.
Definition at line 136 of file Refcounted_Auto_Ptr.h. |
|
|||||
|
Synchronization variable for the MT_SAFE <ACE_Hash_Map_Manager_Ex>.
Definition at line 178 of file Refcounted_Auto_Ptr.h. |
|
|||||
|
Pointer to the result.
Definition at line 170 of file Refcounted_Auto_Ptr.h. |
|
|||||
|
Reference count.
Definition at line 173 of file Refcounted_Auto_Ptr.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002