Panda3D
Public Member Functions
CopyOnWritePointer Class Reference

This safely stores the primary, owned pointer to a CopyOnWriteObject. More...

#include "copyOnWritePointer.h"

Inheritance diagram for CopyOnWritePointer:
CopyOnWritePointerTo< T >

List of all members.

Public Member Functions

 CopyOnWritePointer (CopyOnWriteObject *object=NULL)
 CopyOnWritePointer (const CopyOnWritePointer &copy)
void clear ()
 Sets the pointer to NULL.
const CopyOnWriteObjectget_read_pointer () const
 Returns a pointer locked for read.
CopyOnWriteObjectget_unsafe_pointer ()
 Returns an unlocked pointer that you can write to.
CopyOnWriteObjectget_write_pointer ()
 Returns a pointer locked for write.
bool is_null () const
 Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise.
bool operator!= (const CopyOnWritePointer &other) const
bool operator< (const CopyOnWritePointer &other) const
void operator= (const CopyOnWritePointer &copy)
void operator= (CopyOnWriteObject *object)
bool operator== (const CopyOnWritePointer &other) const
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.

Detailed Description

This safely stores the primary, owned pointer to a CopyOnWriteObject.

At any time, you may call get_read_pointer() or get_write_pointer() to get a read-only or modifiable pointer to the object stored.

There may be multiple copies of a CopyOnWritePointer which all refer to the same shared object. They will negotiate with each other properly.

Definition at line 35 of file copyOnWritePointer.h.


Member Function Documentation

void CopyOnWritePointer::clear ( ) [inline]

Sets the pointer to NULL.

Definition at line 190 of file copyOnWritePointer.I.

Returns a pointer locked for read.

Until this pointer dereferences, calls to get_write_pointer() will force a copy.

This flavor of the method is written for the non-threaded case.

Reimplemented in CopyOnWritePointerTo< T >.

Definition at line 126 of file copyOnWritePointer.I.

Referenced by CopyOnWritePointerTo< T >::get_read_pointer().

Returns an unlocked pointer that you can write to.

This should only be used in very narrow circumstances in which you know that no other thread may be accessing the pointer at the same time.

Reimplemented in CopyOnWritePointerTo< T >.

Definition at line 169 of file copyOnWritePointer.I.

Referenced by CopyOnWritePointerTo< T >::get_unsafe_pointer().

Returns a pointer locked for write.

If another thread or threads already hold the pointer locked for read, then this will force a copy.

Until this pointer dereferences, calls to get_read_pointer() or get_write_pointer() will block.

This flavor of the method is written for the non-threaded case.

Reimplemented in CopyOnWritePointerTo< T >.

Definition at line 146 of file copyOnWritePointer.I.

References CachedTypedWritableReferenceCount::cache_ref(), and CachedTypedWritableReferenceCount::get_cache_ref_count().

Referenced by CopyOnWritePointerTo< T >::get_write_pointer().

bool CopyOnWritePointer::is_null ( ) const [inline]

Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise.

Definition at line 180 of file copyOnWritePointer.I.

Does some easy checks to make sure that the reference count isn't completely bogus.

Returns true if ok, false otherwise.

Definition at line 205 of file copyOnWritePointer.I.

References CachedTypedWritableReferenceCount::test_ref_count_integrity().

Does some easy checks to make sure that the reference count isn't zero, or completely bogus.

Returns true if ok, false otherwise.

Definition at line 218 of file copyOnWritePointer.I.

References ReferenceCount::test_ref_count_nonzero().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations