34 INLINE ReferenceCount::
38 #ifdef DO_MEMORY_USAGE
39 MemoryUsage::record_pointer(
this);
53 INLINE ReferenceCount::
57 #ifdef DO_MEMORY_USAGE
58 MemoryUsage::record_pointer(
this);
75 INLINE
void ReferenceCount::
77 nassertv(
this != NULL);
86 nassertv(_ref_count != deleted_ref_count);
96 TAU_PROFILE(
"ReferenceCount::~ReferenceCount()",
" ", TAU_USER);
97 nassertv(
this != NULL);
106 nassertv(_ref_count != deleted_ref_count);
112 nassertv(_ref_count <= local_ref_count);
117 nassertv(_ref_count >= 0);
129 nassertv(_ref_count == 0 || _ref_count == local_ref_count);
141 _ref_count = deleted_ref_count;
144 #ifdef DO_MEMORY_USAGE
145 MemoryUsage::remove_pointer(
this);
180 TAU_PROFILE(
"void ReferenceCount::ref()",
" ", TAU_USER);
215 TAU_PROFILE(
"void ReferenceCount::unref()",
" ", TAU_USER);
222 nassertr(_ref_count > 0, 0);
237 return do_test_ref_count_integrity();
253 return do_test_ref_count_nonzero();
278 nassertv(_ref_count == 0);
280 _ref_count = local_ref_count;
321 TAU_PROFILE(
"void ReferenceCount::weak_ref()",
" ", TAU_USER);
337 TAU_PROFILE(
"void ReferenceCount::weak_unref()",
" ", TAU_USER);
355 template<
class RefCountType>
357 unref_delete(RefCountType *ptr) {
358 TAU_PROFILE(
"void unref_delete(RefCountType *)",
" ", TAU_USER);
409 operator
const Base &()
const {
422 register_type(_type_handle,
423 "RefCountProxy<" + get_type_handle(Base).get_name() +
">",
424 get_type_handle(Base));
457 #if defined(HAVE_RTTI) && !defined(__EDG__)
459 string base_name =
typeid(Base).name();
461 string base_name =
"unknown";
464 TypeHandle base_type = register_dynamic_type(base_name);
466 ReferenceCount::init_type();
468 register_dynamic_type(
"RefCountObj<" + base_name +
">",
469 base_type, ReferenceCount::get_class_type());
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
void add_reference(WeakPointerToVoid *ptv)
Intended to be called only by WeakPointerTo (or by any class implementing a weak reference-counting p...
void weak_unref(WeakPointerToVoid *ptv)
Removes the indicated PointerToVoid as a weak reference to this object.
static Pointer get_ptr(const Pointer &var)
Atomically retrieves the snapshot value of the indicated variable.
This is the specialization of PointerToVoid for weak pointers.
bool has_weak_list() const
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
This is a list of WeakPointerTo's that share a reference to a given ReferenceCount object...
static void inc(Integer &var)
Atomically increments the indicated variable.
static bool dec(Integer &var)
Atomically decrements the indicated variable and returns true if the new value is nonzero...
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus...
virtual bool unref() const
Explicitly decrements the reference count.
WeakReferenceList * get_weak_list() const
Returns the WeakReferenceList associated with this ReferenceCount object.
static Integer get(const Integer &var)
Atomically retrieves the snapshot value of the indicated variable.
void local_object()
This function should be called, once, immediately after creating a new instance of some ReferenceCoun...
A base class for all things that want to be reference-counted.
void ref() const
Explicitly increments the reference count.
Another kind of proxy, similar to RefCountProxy.
TypeHandle is the identifier used to differentiate C++ class types.
int get_ref_count() const
Returns the current reference count.
void weak_ref(WeakPointerToVoid *ptv)
Adds the indicated PointerToVoid as a weak reference to this object.
A "proxy" to use to make a reference-countable object whenever the object cannot inherit from Referen...