17 INLINE CopyOnWritePointer::
21 if (_cow_object !=
nullptr) {
22 _cow_object->cache_ref();
29 INLINE CopyOnWritePointer::
31 _cow_object(copy._cow_object)
33 if (_cow_object !=
nullptr) {
34 _cow_object->cache_ref();
41 INLINE
void CopyOnWritePointer::
43 operator = (copy._cow_object);
49 INLINE
void CopyOnWritePointer::
51 if (_cow_object !=
object) {
52 if (_cow_object !=
nullptr) {
56 if (_cow_object !=
nullptr) {
65 INLINE CopyOnWritePointer::
66 ~CopyOnWritePointer() {
67 if (_cow_object !=
nullptr) {
75 INLINE CopyOnWritePointer::
77 _cow_object(from._cow_object)
80 from._cow_object =
nullptr;
86 INLINE CopyOnWritePointer::
92 if (_cow_object !=
nullptr) {
93 _cow_object->cache_ref_only();
95 from.cheat() =
nullptr;
101 INLINE
void CopyOnWritePointer::
104 if (from._cow_object != _cow_object) {
106 _cow_object = from._cow_object;
107 from._cow_object =
nullptr;
109 if (old_object !=
nullptr) {
118 INLINE
void CopyOnWritePointer::
120 if (from.p() != _cow_object) {
125 _cow_object = from.p();
127 from.cheat() =
nullptr;
129 if (old_object !=
nullptr) {
138 INLINE
bool CopyOnWritePointer::
140 return _cow_object == other._cow_object;
146 INLINE
bool CopyOnWritePointer::
148 return _cow_object != other._cow_object;
154 INLINE
bool CopyOnWritePointer::
156 return _cow_object < other._cow_object;
170 #endif // COW_THREADED 184 if (_cow_object ==
nullptr) {
190 _cow_object = new_object;
195 #endif // COW_THREADED 213 return (_cow_object ==
nullptr);
221 if (_cow_object !=
nullptr) {
224 _cow_object =
nullptr;
233 nassertr(_cow_object !=
nullptr,
false);
243 nassertr(_cow_object !=
nullptr,
false);
276 CopyOnWritePointer::operator = (copy);
287 CopyOnWritePointer::operator = (
object);
312 _cow_object = from.p();
313 if (_cow_object !=
nullptr) {
314 _cow_object->cache_ref_only();
316 from.cheat() =
nullptr;
338 if (from.p() != _cow_object) {
343 _cow_object = from.p();
345 from.cheat() =
nullptr;
347 if (old_object !=
nullptr) {
364 CPT(
typename CopyOnWritePointerTo<T>::To) to;
366 to.cheat() = (
const To *)from.p();
367 from.cheat() =
nullptr;
370 #else // COW_THREADED 379 #endif // COW_THREADED 392 PT(
typename CopyOnWritePointerTo<T>::To) to;
394 to.cheat() = (To *)from.p();
395 from.cheat() =
nullptr;
398 #else // COW_THREADED 407 #endif // COW_THREADED A template wrapper around the above class, mainly to handle the little typecasting niceties.
bool is_null() const
Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise.
void clear()
Sets the pointer to NULL.
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
To * get_write_pointer()
See CopyOnWritePointer::get_write_pointer().
void cache_unref_delete(RefCountType *ptr)
This global helper function will unref the given ReferenceCount object, and if the reference count re...
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
void cache_ref_only() const
Decrements the cache reference count without affecting the normal reference count.
CopyOnWriteObject * get_write_pointer()
Returns a pointer locked for write.
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
To * get_unsafe_pointer()
See CopyOnWritePointer::get_unsafe_pointer().
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
get_cache_ref_count
Returns the current reference count.
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
This safely stores the primary, owned pointer to a CopyOnWriteObject.
A thread; that is, a lightweight process.
const CopyOnWriteObject * get_read_pointer(Thread *current_thread) const
Returns a pointer locked for read.
This file defines the classes PointerTo and ConstPointerTo (and their abbreviations,...
const To * get_read_pointer(Thread *current_thread=Thread::get_current_thread()) const
See CopyOnWritePointer::get_read_pointer().
CopyOnWriteObject * get_unsafe_pointer()
Returns an unlocked pointer that you can write to.