All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
weakPtr.h File Reference

Pointer storage with deletion detection. More...

+ Include dependency graph for weakPtr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  TfWeakPtr< T >
 Pointer storage with deletion detection. More...
 

Macros

#define TF_SUPPORTS_WEAKPTR(T)   (Tf_SupportsWeakPtr<T>::value)
 
#define TF_TRULY_SUPPORTS_WEAKPTR(T)   std::is_base_of<TfWeakBase, T >::value
 
#define TF_DECLARE_WEAK_POINTABLE_INTERFACE    virtual TfWeakBase const &__GetTfWeakBase__() const = 0
 
#define TF_IMPLEMENT_WEAK_POINTABLE_INTERFACE
 

Functions

template<class U >
TfWeakPtr< U > TfCreateWeakPtr (U *p)
 
template<class U >
TfWeakPtr< U > TfCreateNonConstWeakPtr (U const *p)
 
template<class T >
TfRefPtr< T > TfCreateRefPtrFromProtectedWeakPtr (TfWeakPtr< T > const &p)
 Thread-safe creation of a Tf ref pointer from a Tf weak pointer.
 

Detailed Description

Pointer storage with deletion detection.

Definition in file weakPtr.h.

Macro Definition Documentation

◆ TF_DECLARE_WEAK_POINTABLE_INTERFACE

#define TF_DECLARE_WEAK_POINTABLE_INTERFACE    virtual TfWeakBase const &__GetTfWeakBase__() const = 0

Definition at line 425 of file weakPtr.h.

◆ TF_IMPLEMENT_WEAK_POINTABLE_INTERFACE

#define TF_IMPLEMENT_WEAK_POINTABLE_INTERFACE
Value:
virtual TfWeakBase const &__GetTfWeakBase__() const { \
return *this; \
}
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124

Definition at line 428 of file weakPtr.h.

◆ TF_SUPPORTS_WEAKPTR

#define TF_SUPPORTS_WEAKPTR (   T)    (Tf_SupportsWeakPtr<T>::value)

Definition at line 422 of file weakPtr.h.

◆ TF_TRULY_SUPPORTS_WEAKPTR

#define TF_TRULY_SUPPORTS_WEAKPTR (   T)    std::is_base_of<TfWeakBase, T >::value

Definition at line 423 of file weakPtr.h.

Function Documentation

◆ TfCreateNonConstWeakPtr()

TfWeakPtr< U > TfCreateNonConstWeakPtr ( U const *  p)

Definition at line 235 of file weakPtr.h.

◆ TfCreateRefPtrFromProtectedWeakPtr()

TfRefPtr< T > TfCreateRefPtrFromProtectedWeakPtr ( TfWeakPtr< T > const &  p)

Thread-safe creation of a Tf ref pointer from a Tf weak pointer.

This is thread-safe in the sense that the result will be either a ref pointer to a live object with non-zero ref-count, or a NULL ref pointer. However, this depends on the client to provide a guarantee to protect the pointed-to object.

Specifically, the caller must guarantee that the TfRefBase part of the pointed-to object is not destroyed during this call. It is fine if the destruction process for the object begins (due to the ref-count going to zero as another thread drops the last ref) as long as the TfRefBase portion is not destroyed. If object destruction begins because the ref-count goes to zero before this call completes, this function will reliably return a NULL ref pointer.

Note that this is not a general mechanism for safely converting weak pointers to ref pointers, because it relies on the type T to provide the above guarantee.

Definition at line 260 of file weakPtr.h.

◆ TfCreateWeakPtr()

TfWeakPtr< U > TfCreateWeakPtr ( U *  p)

Definition at line 230 of file weakPtr.h.