5 #ifndef CVMFS_UTIL_SHARED_PTR_H_
6 #define CVMFS_UTIL_SHARED_PTR_H_
12 #ifdef CVMFS_NAMESPACE_GUARD
13 namespace CVMFS_NAMESPACE_GUARD {
14 #endif // CVMFS_NAMESPACE_GUARD
28 value_ =
static_cast<element_type*
>(p);
30 atomic_write64(count_, 1);
36 if (atomic_read64(count_) == 0) {
44 : value_(r.value_), count_(r.count_) {
52 : value_(r.value_), count_(r.count_) {
85 if (atomic_read64(count_) == 0) {
97 value_ =
static_cast<element_type*
>(p);
99 atomic_write64(count_, 1);
110 element_type*
Get()
const {
119 return count_ && (atomic_read64(count_) == 1);
123 return count_ ? atomic_read64(count_) : -1;
131 template <
class T,
class U>
137 template <
class T,
class U>
143 template <
class T,
class U>
145 return a.
value_ < b.value_;
154 template <
class T,
class U>
159 template <
class T,
class U>
164 template <
class T,
class U>
169 template <
class T,
class U>
174 #ifdef CVMFS_NAMESPACE_GUARD
178 #endif // CVMFS_UTIL_SHARED_PTR_H_
SharedPtr< T > ConstPointerCast(SharedPtr< U > const &r)
SharedPtr< T > DynamicPointerCast(SharedPtr< U > const &r)
SharedPtr(SharedPtr< Y > const &r)
SharedPtr< T >::element_type * GetPointer(SharedPtr< T > const &p)
SharedPtr< T > ReinterpretPointerCast(SharedPtr< U > const &r)
SharedPtr< T > StaticPointerCast(SharedPtr< U > const &r)
SharedPtr & operator=(SharedPtr const &r)
bool operator!=(const cvmcache_hash &a, const cvmcache_hash &b)
atomic_int64 * GetCountPtr() const
bool operator==(const cvmcache_hash &a, const cvmcache_hash &b)
element_type * Get() const
SharedPtr(SharedPtr const &r)
SharedPtr & operator=(SharedPtr< Y > const &r)