NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
CSafeStaticPtr_Base Class Reference

Search Toolkit Book for CSafeStaticPtr_Base

CSafeStaticPtr_Base:: More...

#include <corelib/ncbi_safe_static.hpp>

+ Inheritance diagram for CSafeStaticPtr_Base:
+ Collaboration diagram for CSafeStaticPtr_Base:

Public Types

typedef void(* FUserCleanup) (void *ptr)
 User cleanup function type. More...
 
typedef CSafeStaticLifeSpan TLifeSpan
 Life span. More...
 

Public Member Functions

 ~CSafeStaticPtr_Base (void)
 

Protected Types

typedef CGuard< CSafeStaticPtr_BaseTInstanceMutexGuard
 
typedef void(* FSelfCleanup) (CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard)
 Cleanup function type used by derived classes. More...
 

Protected Member Functions

 CSafeStaticPtr_Base (FSelfCleanup self_cleanup, FUserCleanup user_cleanup=0, TLifeSpan life_span=TLifeSpan::GetDefault())
 Constructor. More...
 
 DECLARE_CLASS_STATIC_MUTEX (sm_ClassMutex)
 
const void * x_GetPtr () const
 
void x_SetPtr (const void *ptr)
 
bool x_IsSetPtr () const
 
const void * x_ReleasePtr ()
 
bool x_IsStdStatic (void) const
 
void x_Cleanup (void)
 

Static Protected Member Functions

static int x_GetCreationOrder (void)
 

Protected Attributes

atomic< const void * > m_Ptr
 Pointer to the data. More...
 
FSelfCleanup m_SelfCleanup
 
FUserCleanup m_UserCleanup
 
TLifeSpan m_LifeSpan
 
int m_CreationOrder
 
int m_MutexRefCount
 
CMutexm_InstanceMutex
 

Private Member Functions

void Lock (void)
 
void Unlock (void)
 
void x_ReleaseInstanceMutex (void)
 

Friends

struct SSimpleLock< CSafeStaticPtr_Base >
 
struct SSimpleUnlock< CSafeStaticPtr_Base >
 
class CSafeStatic_Less
 
class CSafeStaticGuard
 

Detailed Description

CSafeStaticPtr_Base::

Base class for CSafeStaticPtr<> and CSafeStaticRef<> templates.

Definition at line 115 of file ncbi_safe_static.hpp.

Member Typedef Documentation

◆ FSelfCleanup

typedef void(* CSafeStaticPtr_Base::FSelfCleanup) (CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard)
protected

Cleanup function type used by derived classes.

Definition at line 130 of file ncbi_safe_static.hpp.

◆ FUserCleanup

typedef void(* CSafeStaticPtr_Base::FUserCleanup) (void *ptr)

User cleanup function type.

Definition at line 119 of file ncbi_safe_static.hpp.

◆ TInstanceMutexGuard

Definition at line 127 of file ncbi_safe_static.hpp.

◆ TLifeSpan

Life span.

Definition at line 122 of file ncbi_safe_static.hpp.

Constructor & Destructor Documentation

◆ ~CSafeStaticPtr_Base()

CSafeStaticPtr_Base::~CSafeStaticPtr_Base ( void  )

Definition at line 99 of file ncbi_safe_static.cpp.

References x_Cleanup(), and x_IsStdStatic().

◆ CSafeStaticPtr_Base()

CSafeStaticPtr_Base::CSafeStaticPtr_Base ( FSelfCleanup  self_cleanup,
FUserCleanup  user_cleanup = 0,
TLifeSpan  life_span = TLifeSpan::GetDefault() 
)
inlineprotected

Constructor.

Parameters
self_cleanupCleanup function to be executed on destruction, provided by a derived class.
user_cleanupUser-provided cleanup function to be executed on destruction.
life_spanLife span allows to control destruction of objects. Objects with the same life span are destroyed in the order reverse to their creation order.
See also
CSafeStaticLifeSpan

Definition at line 145 of file ncbi_safe_static.hpp.

Member Function Documentation

◆ DECLARE_CLASS_STATIC_MUTEX()

CSafeStaticPtr_Base::DECLARE_CLASS_STATIC_MUTEX ( sm_ClassMutex  )
protected

◆ Lock()

void CSafeStaticPtr_Base::Lock ( void  )
inlineprivate

◆ Unlock()

void CSafeStaticPtr_Base::Unlock ( void  )
inlineprivate

Definition at line 195 of file ncbi_safe_static.hpp.

References m_InstanceMutex, CMutex::Unlock(), and x_ReleaseInstanceMutex().

◆ x_Cleanup()

void CSafeStaticPtr_Base::x_Cleanup ( void  )
inlineprotected

Definition at line 236 of file ncbi_safe_static.hpp.

References m_SelfCleanup, and x_ReleaseInstanceMutex().

Referenced by ~CSafeStaticPtr_Base().

◆ x_GetCreationOrder()

int CSafeStaticPtr_Base::x_GetCreationOrder ( void  )
staticprotected

Definition at line 92 of file ncbi_safe_static.cpp.

References CAtomicCounter::Add(), and int.

◆ x_GetPtr()

const void* CSafeStaticPtr_Base::x_GetPtr ( ) const
inlineprotected

◆ x_IsSetPtr()

bool CSafeStaticPtr_Base::x_IsSetPtr ( ) const
inlineprotected

◆ x_IsStdStatic()

bool CSafeStaticPtr_Base::x_IsStdStatic ( void  ) const
inlineprotected

◆ x_ReleaseInstanceMutex()

void CSafeStaticPtr_Base::x_ReleaseInstanceMutex ( void  )
inlineprivate

Definition at line 201 of file ncbi_safe_static.hpp.

References m_InstanceMutex, m_MutexRefCount, and tmp.

Referenced by Unlock(), and x_Cleanup().

◆ x_ReleasePtr()

const void* CSafeStaticPtr_Base::x_ReleasePtr ( )
inlineprotected

◆ x_SetPtr()

void CSafeStaticPtr_Base::x_SetPtr ( const void *  ptr)
inlineprotected

Friends And Related Function Documentation

◆ CSafeStatic_Less

friend class CSafeStatic_Less
friend

Definition at line 215 of file ncbi_safe_static.hpp.

◆ CSafeStaticGuard

friend class CSafeStaticGuard
friend

Definition at line 235 of file ncbi_safe_static.hpp.

◆ SSimpleLock< CSafeStaticPtr_Base >

friend struct SSimpleLock< CSafeStaticPtr_Base >
friend

Definition at line 169 of file ncbi_safe_static.hpp.

◆ SSimpleUnlock< CSafeStaticPtr_Base >

friend struct SSimpleUnlock< CSafeStaticPtr_Base >
friend

Definition at line 169 of file ncbi_safe_static.hpp.

Member Data Documentation

◆ m_CreationOrder

int CSafeStaticPtr_Base::m_CreationOrder
protected

Definition at line 220 of file ncbi_safe_static.hpp.

Referenced by CSafeStatic_Less::operator()().

◆ m_InstanceMutex

CMutex* CSafeStaticPtr_Base::m_InstanceMutex
protected

Definition at line 222 of file ncbi_safe_static.hpp.

Referenced by Lock(), Unlock(), and x_ReleaseInstanceMutex().

◆ m_LifeSpan

TLifeSpan CSafeStaticPtr_Base::m_LifeSpan
protected

◆ m_MutexRefCount

int CSafeStaticPtr_Base::m_MutexRefCount
protected

Definition at line 221 of file ncbi_safe_static.hpp.

Referenced by Lock(), and x_ReleaseInstanceMutex().

◆ m_Ptr

atomic<const void*> CSafeStaticPtr_Base::m_Ptr
protected

Pointer to the data.

Definition at line 155 of file ncbi_safe_static.hpp.

Referenced by x_GetPtr(), and x_SetPtr().

◆ m_SelfCleanup

FSelfCleanup CSafeStaticPtr_Base::m_SelfCleanup
protected

Definition at line 217 of file ncbi_safe_static.hpp.

Referenced by x_Cleanup().

◆ m_UserCleanup

FUserCleanup CSafeStaticPtr_Base::m_UserCleanup
protected

The documentation for this class was generated from the following files:
Modified on Tue May 21 10:53:47 2024 by modify_doxy.py rev. 669887