libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::sp_counter_type< Val, LkT, Del, AtCtr > Class Template Reference

The intrusive counter that an object must also inherit from for the shared_ptr class to work. More...

#include <shared_ptr.hpp>

Inherits AtCtr< Val >.

Public Types

using base_t = sp_counter_itf_type< Val >
 
using value_type = typename base_t::value_type
 
using atomic_ctr_t = AtCtr< value_type >
 
using lock_traits = LkT
 
typedef Del< sp_counter_typedeleter_t
 Make sure the correct object deletion mechanism is used. More...
 

Public Member Functions

virtual ~sp_counter_type () noexcept(true)=default
 
void deleter () override
 Call the correct deleter_t object to delete the object. More...
 
value_type sp_count () const noexcept(true) override final
 
atomic_ctr_t::value_type sp_acquire () noexcept(true) override final
 
bool sp_release () noexcept(true) override final
 
bool __fastcall operator< (const value_type v) const noexcept(true) override
 
bool __fastcall operator> (const value_type v) const noexcept(true) override
 
bool __fastcall operator>= (const value_type v) const noexcept(true) override final
 
tstring sp_to_string () const noexcept(false) override final
 

Static Public Attributes

static constexpr ppd::generic_traits::memory_access_modes memory_access_mode =atomic_ctr_t::memory_access_mode
 

Protected Member Functions

constexpr sp_counter_type () noexcept(true)
 

Friends

template<class , class >
class shared_ptr
 
template<class , class >
class intrusive::slist
 

Detailed Description

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
class jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >

The intrusive counter that an object must also inherit from for the shared_ptr class to work.

A client must inherit from this class to allow the shared_ptr to operate. If the client also wants to specify at run-time which counter or deletion method is to be used, then some base in their hierarchy must also inherit from sp_counter_itf_type.

By default the counter is a "simple" (cough) sequential counter, with the threading model specified via the lock_traits.

See also
sp_counter_itf_type, shared_ptr

Definition at line 63 of file shared_ptr.hpp.

Member Typedef Documentation

◆ atomic_ctr_t

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
using jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::atomic_ctr_t = AtCtr<value_type>

Definition at line 67 of file shared_ptr.hpp.

◆ base_t

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
using jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::base_t = sp_counter_itf_type<Val>

Definition at line 65 of file shared_ptr.hpp.

◆ deleter_t

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
typedef Del<sp_counter_type> jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::deleter_t

Make sure the correct object deletion mechanism is used.

Note this this allows the user to specify multiple features:

  1. That the correct deleter is used with the allocator.
  2. That if the static type of the object is known at compile-time the deleter can be used with little or no performance loss.
  3. That the deleter may be dynamically specified in a derived class, allowing the share_ptr to contain objects that also vary by the specific deleter that the derived type will use. For example there may be a collection of base-pointers, the derived objects of which may be dynamically, placement-new or stack-allocated and upon extracting them from the collection, the shared_ptr class can accommodate deleting all of them because of the flexibility introduced in sp_counter_itf_type::deleter().
See also
sp_counter_itf_type::deleter_t, sp_counter_itf_type::deleter()

Definition at line 78 of file shared_ptr.hpp.

◆ lock_traits

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
using jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::lock_traits = LkT

This does not have to be the same as the atomic_ctr_t, as we may want the flexibility to deal with the type differently in this case.

Definition at line 68 of file shared_ptr.hpp.

◆ value_type

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
using jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::value_type = typename base_t::value_type

Definition at line 66 of file shared_ptr.hpp.

Constructor & Destructor Documentation

◆ ~sp_counter_type()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
virtual jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::~sp_counter_type ( )
virtualdefaultnoexcept

◆ sp_counter_type()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
constexpr jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::sp_counter_type ( )
inlineconstexprprotectednoexcept

Definition at line 126 of file shared_ptr.hpp.

Member Function Documentation

◆ deleter()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
void jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::deleter ( )
inlineoverride

Call the correct deleter_t object to delete the object.

Note that we are calling the dtor on the object from within a virtual function, which is allowed. (The converse is not, of course.)

Definition at line 93 of file shared_ptr.hpp.

◆ operator<()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
bool __fastcall jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::operator< ( const value_type  v) const
inlineoverridenoexcept

Definition at line 108 of file shared_ptr.hpp.

◆ operator>()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
bool __fastcall jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::operator> ( const value_type  v) const
inlineoverridenoexcept

Definition at line 111 of file shared_ptr.hpp.

◆ operator>=()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
bool __fastcall jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::operator>= ( const value_type  v) const
inlinefinaloverridenoexcept

Definition at line 114 of file shared_ptr.hpp.

◆ sp_acquire()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
atomic_ctr_t::value_type jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::sp_acquire ( )
inlinefinaloverridenoexcept

Definition at line 100 of file shared_ptr.hpp.

◆ sp_count()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
value_type jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::sp_count ( ) const
inlinefinaloverridenoexcept

Definition at line 97 of file shared_ptr.hpp.

◆ sp_release()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
bool jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::sp_release ( )
inlinefinaloverridenoexcept

Definition at line 104 of file shared_ptr.hpp.

◆ sp_to_string()

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
tstring jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::sp_to_string ( ) const
inlinefinaloverridenoexcept

Definition at line 119 of file shared_ptr.hpp.

Friends And Related Function Documentation

◆ intrusive::slist

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
template<class , class >
friend class intrusive::slist
friend

Definition at line 130 of file shared_ptr.hpp.

◆ shared_ptr

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
template<class , class >
friend class shared_ptr
friend

Definition at line 129 of file shared_ptr.hpp.

Member Data Documentation

◆ memory_access_mode

template<class Val, class LkT, template< class > class Del = jmmcg::default_delete, template< class > class AtCtr = LkT::template atomic_counter_type>
constexpr ppd::generic_traits::memory_access_modes jmmcg::sp_counter_type< Val, LkT, Del, AtCtr >::memory_access_mode =atomic_ctr_t::memory_access_mode
staticconstexpr

To assist in allowing compile-time computation of the algorithmic order of the threading model.

Definition at line 83 of file shared_ptr.hpp.


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