Changeset 700 for handle/trunk
- Timestamp:
- 08/07/08 09:58:11 (2 years ago)
- Files:
-
- 1 modified
-
handle/trunk/handle.h (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
handle/trunk/handle.h
r238 r700 27 27 #include <cxxabi.h> 28 28 #endif 29 30 #define BOOST_NO_CONFIG 31 #define BOOST_HAS_THREADS 32 #include "atomic/boost/detail/atomic_count.hpp" 29 33 30 34 using std::size_t; //everyone uses it.. … … 82 86 }; 83 87 88 using boost::detail::atomic_count; 89 84 90 /** 85 91 * Your standard reference counting handle with some … … 92 98 template <class C> friend class Handle; 93 99 T* p; ///< The pointer we are counting 94 size_t* refs; ///< Pointer to the number of references to \a p100 atomic_count* refs; ///< Pointer to the number of references to \a p 95 101 96 102 /** … … 99 105 * have to check for self-assignment. 100 106 */ 101 void safeAssign(size_t* newRefs) throw() { 102 size_t* oldRefs(refs); 103 refs = &++*newRefs; 107 void safeAssign(atomic_count* newRefs) throw() { 108 atomic_count* oldRefs(refs); 109 ++*newRefs; 110 refs = newRefs; 104 111 if (!--*oldRefs) { 105 112 delp(); … … 114 121 * Construct a <tt>new T()</tt> with \a T's default constructor. 115 122 */ 116 Handle () throw(std::bad_alloc) : p(new T()) , refs(new size_t(1)) {}123 Handle () throw(std::bad_alloc) : p(new T()) , refs(new atomic_count(1)) {} 117 124 118 125 /** … … 128 135 * \param pp The pointer to attach 129 136 */ 130 explicit Handle (T* pp) throw(std::bad_alloc) : p(pp), refs(new size_t(1)) {}137 explicit Handle (T* pp) throw(std::bad_alloc) : p(pp), refs(new atomic_count(1)) {} 131 138 132 139 /** Return the number of references to the pointer */ … … 138 145 * \param h the Handle to copy 139 146 */ 140 Handle (const Handle<T>& h) throw() : p(h.p), refs(&++*h.refs) {} 147 Handle (const Handle<T>& h) throw() : p(h.p), refs(h.refs) { 148 ++*refs; 149 } 141 150 142 151 /**
