Panda3D

Loading...
Searching...
No Matches
Public Member Functions | List of all members
CopyOnWritePointer Class Reference

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

`#include "copyOnWritePointer.h"`

Inheritance diagram for CopyOnWritePointer:

## Public Member Functions
| CopyOnWritePointer (const CopyOnWritePointer &copy)
| CopyOnWritePointer (CopyOnWriteObject *object=nullptr)
| CopyOnWritePointer (CopyOnWritePointer &&from) noexcept
| CopyOnWritePointer (PointerTo< CopyOnWriteObject > &&from) noexcept
void | clear ()
| Sets the pointer to NULL.
const CopyOnWriteObject * | get_read_pointer (Thread *current_thread) const
| Returns a pointer locked for read.
CopyOnWriteObject * | get_unsafe_pointer ()
| Returns an unlocked pointer that you can write to.
CopyOnWriteObject * | get_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)
void | operator= (CopyOnWritePointer &&from) noexcept
void | operator= (PointerTo< CopyOnWriteObject > &&from) noexcept
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 31 of file copyOnWritePointer.h.

## Constructor & Destructor Documentation

## ◆ CopyOnWritePointer() [1/4]

CopyOnWritePointer::CopyOnWritePointer | ( | CopyOnWriteObject * | object = nullptr | ) |
| inline

Definition at line 17 of file copyOnWritePointer.I.

## ◆ CopyOnWritePointer() [2/4]

CopyOnWritePointer::CopyOnWritePointer | ( | const CopyOnWritePointer & | copy | ) |
| inline

Definition at line 29 of file copyOnWritePointer.I.

## ◆ CopyOnWritePointer() [3/4]

CopyOnWritePointer::CopyOnWritePointer | ( | CopyOnWritePointer && | from | ) |
| inline noexcept

Definition at line 75 of file copyOnWritePointer.I.

## ◆ CopyOnWritePointer() [4/4]

CopyOnWritePointer::CopyOnWritePointer | ( | PointerTo< CopyOnWriteObject > && | from | ) |
| inline noexcept

Definition at line 86 of file copyOnWritePointer.I.

## ◆ ~CopyOnWritePointer()

CopyOnWritePointer::~CopyOnWritePointer | ( |  | ) |
| inline

Definition at line 65 of file copyOnWritePointer.I.

## Member Function Documentation

## ◆ clear()

void CopyOnWritePointer::clear | ( |  | ) |
| inline

Sets the pointer to NULL.

Definition at line 219 of file copyOnWritePointer.I.

References cache_unref_delete().

## ◆ get_read_pointer()

const CopyOnWriteObject * CopyOnWritePointer::get_read_pointer | ( | Thread * | current_thread | ) | const
| inline

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.

Definition at line 166 of file copyOnWritePointer.I.

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

## ◆ get_unsafe_pointer()

CopyOnWriteObject * CopyOnWritePointer::get_unsafe_pointer | ( |  | ) |
| inline

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.

Definition at line 202 of file copyOnWritePointer.I.

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

## ◆ get_write_pointer()

CopyOnWriteObject * CopyOnWritePointer::get_write_pointer | ( |  | ) |
| inline

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.

Definition at line 182 of file copyOnWritePointer.I.

References cache_unref_delete().

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

## ◆ is_null()

bool CopyOnWritePointer::is_null | ( |  | ) | const
| inline

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

Definition at line 211 of file copyOnWritePointer.I.

## ◆ operator!=()

bool CopyOnWritePointer::operator!= | ( | const CopyOnWritePointer & | other | ) | const
| inline

Definition at line 146 of file copyOnWritePointer.I.

## ◆ operator<()

bool CopyOnWritePointer::operator< | ( | const CopyOnWritePointer & | other | ) | const
| inline

Definition at line 154 of file copyOnWritePointer.I.

## ◆ operator=() [1/4]

void CopyOnWritePointer::operator= | ( | const CopyOnWritePointer & | copy | ) |
| inline

Definition at line 41 of file copyOnWritePointer.I.

## ◆ operator=() [2/4]

void CopyOnWritePointer::operator= | ( | CopyOnWriteObject * | object | ) |
| inline

Definition at line 49 of file copyOnWritePointer.I.

## ◆ operator=() [3/4]

void CopyOnWritePointer::operator= | ( | CopyOnWritePointer && | from | ) |
| inline noexcept

Definition at line 101 of file copyOnWritePointer.I.

## ◆ operator=() [4/4]

void CopyOnWritePointer::operator= | ( | PointerTo< CopyOnWriteObject > && | from | ) |
| inline noexcept

Definition at line 118 of file copyOnWritePointer.I.

## ◆ operator==()

bool CopyOnWritePointer::operator== | ( | const CopyOnWritePointer & | other | ) | const
| inline

Definition at line 138 of file copyOnWritePointer.I.

## ◆ test_ref_count_integrity()

bool CopyOnWritePointer::test_ref_count_integrity | ( |  | ) | const
| inline

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

Returns true if ok, false otherwise.

Definition at line 231 of file copyOnWritePointer.I.

Referenced by GeomNode::decompose(), and GeomNode::unify().

## ◆ test_ref_count_nonzero()

bool CopyOnWritePointer::test_ref_count_nonzero | ( |  | ) | const
| inline

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 241 of file copyOnWritePointer.I.

The documentation for this class was generated from the following files:

- panda/src/putil/copyOnWritePointer.h
- panda/src/putil/copyOnWritePointer.I