Panda3D
|
This is a special extension to ReferenceCount that includes dual reference counts: the standard reference count number, which includes all references to the object, and a separate number (the cache reference count) that counts the number of references to the object just within its cache alone. More...
#include "cachedTypedWritableReferenceCount.h"
Public Member Functions | |
void | cache_ref () const |
Explicitly increments the cache reference count and the normal reference count simultaneously. | |
bool | cache_unref () const |
Explicitly decrements the cache reference count and the normal reference count simultaneously. | |
int | get_cache_ref_count () const |
Returns the current reference count. | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
CachedTypedWritableReferenceCount () | |
The ReferenceCount constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try. | |
CachedTypedWritableReferenceCount (const CachedTypedWritableReferenceCount ©) | |
The copies of reference-counted objects do not themselves inherit the reference count! | |
~CachedTypedWritableReferenceCount () | |
The ReferenceCount destructor is protected to discourage users from accidentally trying to delete a ReferenceCount pointer directly. | |
void | cache_unref_only () const |
Decrements the cache reference count without affecting the normal reference count. | |
bool | do_test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
void | operator= (const CachedTypedWritableReferenceCount ©) |
The copies of reference-counted objects do not themselves inherit the reference count! |
This is a special extension to ReferenceCount that includes dual reference counts: the standard reference count number, which includes all references to the object, and a separate number (the cache reference count) that counts the number of references to the object just within its cache alone.
When get_ref_count() == get_cache_ref_count(), the object is not referenced outside the cache.
The cache refs must be explicitly maintained; there is no PointerTo<> class to maintain the cache reference counts automatically. The cache reference count is automatically included in the overall reference count: calling cache_ref() and cache_unref() automatically calls ref() and unref().
Definition at line 40 of file cachedTypedWritableReferenceCount.h.
CachedTypedWritableReferenceCount::CachedTypedWritableReferenceCount | ( | ) | [inline, protected] |
The ReferenceCount constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try.
ReferenceCount doesn't store any useful information in its own right; its only purpose is to add reference-counting to some other class via inheritance.
Definition at line 30 of file cachedTypedWritableReferenceCount.I.
CachedTypedWritableReferenceCount::CachedTypedWritableReferenceCount | ( | const CachedTypedWritableReferenceCount & | copy | ) | [inline, protected] |
The copies of reference-counted objects do not themselves inherit the reference count!
This copy constructor is protected because you almost never want to create just a ReferenceCount object by itself, and it's probably a mistake if you try.
Definition at line 45 of file cachedTypedWritableReferenceCount.I.
CachedTypedWritableReferenceCount::~CachedTypedWritableReferenceCount | ( | ) | [inline, protected] |
The ReferenceCount destructor is protected to discourage users from accidentally trying to delete a ReferenceCount pointer directly.
This is almost always a bad idea, since the destructor is not virtual, and you've almost certainly got some pointer to something that inherits from ReferenceCount, not just a plain old ReferenceCount object.
Definition at line 90 of file cachedTypedWritableReferenceCount.I.
void CachedTypedWritableReferenceCount::cache_ref | ( | ) | const [inline] |
Explicitly increments the cache reference count and the normal reference count simultaneously.
Reimplemented in TransformState, and RenderState.
Definition at line 147 of file cachedTypedWritableReferenceCount.I.
References ReferenceCount::ref(), and test_ref_count_integrity().
Referenced by CopyOnWritePointer::get_write_pointer().
bool CachedTypedWritableReferenceCount::cache_unref | ( | ) | const [inline] |
Explicitly decrements the cache reference count and the normal reference count simultaneously.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in TransformState, and RenderState.
Definition at line 166 of file cachedTypedWritableReferenceCount.I.
References test_ref_count_integrity(), and ReferenceCount::unref().
void CachedTypedWritableReferenceCount::cache_unref_only | ( | ) | const [inline, protected] |
Decrements the cache reference count without affecting the normal reference count.
Intended to be called by derived classes only, presumably to reimplement cache_unref().
Definition at line 204 of file cachedTypedWritableReferenceCount.I.
References test_ref_count_integrity().
bool CachedTypedWritableReferenceCount::do_test_ref_count_integrity | ( | ) | const [protected] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Reimplemented from ReferenceCount.
Reimplemented in NodeCachedReferenceCount.
Definition at line 26 of file cachedTypedWritableReferenceCount.cxx.
Referenced by test_ref_count_integrity().
int CachedTypedWritableReferenceCount::get_cache_ref_count | ( | ) | const [inline] |
Returns the current reference count.
Definition at line 133 of file cachedTypedWritableReferenceCount.I.
References test_ref_count_integrity().
Referenced by RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), NodeCachedReferenceCount::get_referenced_bits(), CopyOnWritePointer::get_write_pointer(), RenderState::unref(), and TransformState::unref().
void CachedTypedWritableReferenceCount::operator= | ( | const CachedTypedWritableReferenceCount & | copy | ) | [inline, protected] |
The copies of reference-counted objects do not themselves inherit the reference count!
This copy assignment operator is protected because you almost never want to copy just a ReferenceCount object by itself, and it's probably a mistake if you try. Instead, this should only be called from a derived class that implements this operator and then calls up the inheritance chain.
Definition at line 63 of file cachedTypedWritableReferenceCount.I.
bool CachedTypedWritableReferenceCount::test_ref_count_integrity | ( | ) | const [inline] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Reimplemented from ReferenceCount.
Reimplemented in NodeCachedReferenceCount.
Definition at line 187 of file cachedTypedWritableReferenceCount.I.
References do_test_ref_count_integrity().
Referenced by cache_ref(), cache_unref(), cache_unref_only(), get_cache_ref_count(), and CopyOnWritePointer::test_ref_count_integrity().