PStack  2.0
Stack trace printer for MSVC and GCC binaries
psystem::shared_handle< T, kInvalidHandle >::shared_handle_data Struct Reference

The basic control block for a shared_handle. More...

Inheritance diagram for psystem::shared_handle< T, kInvalidHandle >::shared_handle_data:

Public Member Functions

 shared_handle_data () noexcept
 Initialize a usage count of 1 and a weak-usage count of 1.
 
virtual ~shared_handle_data () noexcept
 Provide a virtual destructor for polymorphic deletion.
 
virtual void delete_handle (T hndl) noexcept
 Remove resources associated with a handle. More...
 

Public Attributes

std::atomic< size_t > m_usage_count
 The count of shared_handle instances that are managing this handle.
 
std::atomic< size_t > m_weak_count
 The "weak" reference count (manages the control block). More...
 

Detailed Description

template<typename T = HANDLE, T kInvalidHandle = INVALID_HANDLE_VALUE>
struct psystem::shared_handle< T, kInvalidHandle >::shared_handle_data

The basic control block for a shared_handle.

This is a "basic" control block because it does not support a custom deleter.

Member Function Documentation

template<typename T = HANDLE, T kInvalidHandle = INVALID_HANDLE_VALUE>
virtual void psystem::shared_handle< T, kInvalidHandle >::shared_handle_data::delete_handle ( hndl)
inlinevirtualnoexcept

Remove resources associated with a handle.

The intention of this method is for cleaning the handle that is managed by a shared_handle instance. This is a virtual method because the derived class may use a different deleter.

Parameters
[in]hndlThe handle to close.
Note
If I didn't have to support the deleter being provided in construction (to match the std::shared_ptr interface), I wouldn't need the control block to have a template param (or a vtable).

Reimplemented in psystem::shared_handle< T, kInvalidHandle >::shared_handle_data_with_delete< D >.

Member Data Documentation

template<typename T = HANDLE, T kInvalidHandle = INVALID_HANDLE_VALUE>
std::atomic<size_t> psystem::shared_handle< T, kInvalidHandle >::shared_handle_data::m_weak_count

The "weak" reference count (manages the control block).

This is the count of weak_handle instances — plus 1 if there are active shared_handle instances.


The documentation for this struct was generated from the following file: