Panda3D
Public Member Functions | Public Attributes | Friends | List of all members
WeakReferenceList Class Reference

This is an object shared by all the weak pointers that point to the same ReferenceCount object. More...

#include "weakReferenceList.h"

Public Member Functions

 ~WeakReferenceList ()
 The destructor tells all of the owned references that we're gone. More...
 
void add_callback (WeakPointerCallback *callback, void *data)
 Adds the callback to the list of callbacks that will be called when the underlying pointer is deleted. More...
 
void ref () const
 Increases the number of weak references. More...
 
void remove_callback (WeakPointerCallback *callback)
 Intended to be called only by WeakPointerTo (or by any class implementing a weak reference-counting pointer), this removes the indicated PointerToVoid structure from the list of such structures that are maintaining a weak pointer to this object. More...
 
bool unref () const
 Decreases the number of weak references. More...
 
bool was_deleted () const
 Returns true if the object represented has been deleted, ie. More...
 

Public Attributes

MutexImpl _lock
 

Friends

class ReferenceCount
 

Detailed Description

This is an object shared by all the weak pointers that point to the same ReferenceCount object.

It is created whenever a weak reference to an object is created, and can outlive the object until all weak references have disappeared.

Definition at line 29 of file weakReferenceList.h.

Constructor & Destructor Documentation

◆ ~WeakReferenceList()

WeakReferenceList::~WeakReferenceList ( )

The destructor tells all of the owned references that we're gone.

Definition at line 29 of file weakReferenceList.cxx.

Member Function Documentation

◆ add_callback()

void WeakReferenceList::add_callback ( WeakPointerCallback callback,
void *  data 
)

Adds the callback to the list of callbacks that will be called when the underlying pointer is deleted.

If it has already been deleted, it will be called immediately.

The data pointer can be an arbitrary pointer and is passed as only argument to the callback.

Since
1.10.0

Definition at line 44 of file weakReferenceList.cxx.

Referenced by WeakPointerToVoid::add_callback().

◆ ref()

void WeakReferenceList::ref ( ) const
inline

Increases the number of weak references.

Since
1.10.0

Definition at line 20 of file weakReferenceList.I.

References AtomicAdjustDummyImpl::inc().

◆ remove_callback()

void WeakReferenceList::remove_callback ( WeakPointerCallback callback)

Intended to be called only by WeakPointerTo (or by any class implementing a weak reference-counting pointer), this removes the indicated PointerToVoid structure from the list of such structures that are maintaining a weak pointer to this object.

Since
1.10.0

Definition at line 70 of file weakReferenceList.cxx.

Referenced by WeakPointerToVoid::remove_callback().

◆ unref()

bool WeakReferenceList::unref ( ) const
inline

Decreases the number of weak references.

Returns true if, after this, there are still any weak or strong references remaining, or false if this structure should be deleted right away.

Since
1.10.0

Definition at line 32 of file weakReferenceList.I.

References AtomicAdjustDummyImpl::dec().

Referenced by WeakPointerToBase< T >::clear().

◆ was_deleted()

bool WeakReferenceList::was_deleted ( ) const
inline

Returns true if the object represented has been deleted, ie.

there are only weak references left pointing to the object.

Since
1.10.0

Definition at line 43 of file weakReferenceList.I.

References AtomicAdjustDummyImpl::get().

Referenced by WeakPointerToVoid::add_callback(), WeakPointerToVoid::is_valid_pointer(), WeakPointerToBase< T >::output(), and WeakPointerToVoid::was_deleted().


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