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

Search Toolkit Book for CSafeStaticGuard

CSafeStaticGuard:: More...

#include <corelib/ncbi_safe_static.hpp>

Public Member Functions

 CSafeStaticGuard (void)
 Check if already initialized. More...
 
 ~CSafeStaticGuard (void)
 Check reference count, and if it is zero, then destroy all registered variables. More...
 

Static Public Member Functions

static void Register (CSafeStaticPtr_Base *ptr)
 Add new on-demand variable to the cleanup stack. More...
 
static void DisableChildThreadsCheck ()
 Disable checking on child thread(s) running during destruction. More...
 
static void Destroy (CSafeStaticLifeSpan::ELifeLevel level)
 Explicitly destroy all on-demand variables up to a specified level. More...
 

Private Types

typedef multiset< CSafeStaticPtr_Base *, CSafeStatic_LessTStack
 

Static Private Member Functions

static CSafeStaticGuardx_Get (void)
 
static TStack *& x_GetStack (CSafeStaticLifeSpan::ELifeLevel level)
 
static void x_Cleanup (CMutexGuard &guard, TStack *&stack)
 

Static Private Attributes

static int sm_RefCount
 
static bool sm_ChildThreadsCheck = true
 

Detailed Description

CSafeStaticGuard::

Register all on-demand variables, destroy them on the program termination.

Definition at line 273 of file ncbi_safe_static.hpp.

Member Typedef Documentation

◆ TStack

Definition at line 311 of file ncbi_safe_static.hpp.

Constructor & Destructor Documentation

◆ CSafeStaticGuard()

CSafeStaticGuard::CSafeStaticGuard ( void  )

Check if already initialized.

If not - create the stack, otherwise just increment the reference count.

Definition at line 126 of file ncbi_safe_static.cpp.

References CSafeStaticLifeSpan::eLifeLevel_AppMain, CSafeStaticLifeSpan::eLifeLevel_Default, sm_RefCount, and x_GetStack().

Referenced by x_Get().

◆ ~CSafeStaticGuard()

CSafeStaticGuard::~CSafeStaticGuard ( void  )

Member Function Documentation

◆ Destroy()

void CSafeStaticGuard::Destroy ( CSafeStaticLifeSpan::ELifeLevel  level)
static

Explicitly destroy all on-demand variables up to a specified level.

Definition at line 144 of file ncbi_safe_static.cpp.

References CSafeStaticLifeSpan::eLifeLevel_AppMain, CSafeStaticLifeSpan::eLifeLevel_Default, x_Cleanup(), and x_GetStack().

Referenced by CNcbiApplicationAPI::AppMain(), and CNcbiTestApplication::FiniTestsAfterRun().

◆ DisableChildThreadsCheck()

void CSafeStaticGuard::DisableChildThreadsCheck ( )
static

Disable checking on child thread(s) running during destruction.

Definition at line 138 of file ncbi_safe_static.cpp.

References sm_ChildThreadsCheck.

Referenced by CNcbiApplicationAPI::x_HonorStandardSettings().

◆ Register()

static void CSafeStaticGuard::Register ( CSafeStaticPtr_Base ptr)
inlinestatic

◆ x_Cleanup()

void CSafeStaticGuard::x_Cleanup ( CMutexGuard guard,
TStack *&  stack 
)
staticprivate

◆ x_Get()

CSafeStaticGuard * CSafeStaticGuard::x_Get ( void  )
staticprivate

Definition at line 216 of file ncbi_safe_static.cpp.

References CSafeStaticGuard(), and sh_CleanupGuard.

Referenced by Register().

◆ x_GetStack()

static TStack*& CSafeStaticGuard::x_GetStack ( CSafeStaticLifeSpan::ELifeLevel  level)
inlinestaticprivate

Definition at line 314 of file ncbi_safe_static.hpp.

References _ASSERT.

Referenced by CSafeStaticGuard(), Destroy(), Register(), and ~CSafeStaticGuard().

Member Data Documentation

◆ sm_ChildThreadsCheck

bool CSafeStaticGuard::sm_ChildThreadsCheck = true
staticprivate

Definition at line 332 of file ncbi_safe_static.hpp.

Referenced by DisableChildThreadsCheck(), and ~CSafeStaticGuard().

◆ sm_RefCount

int CSafeStaticGuard::sm_RefCount
staticprivate

Definition at line 329 of file ncbi_safe_static.hpp.

Referenced by CSafeStaticGuard(), Register(), and ~CSafeStaticGuard().


The documentation for this class was generated from the following files:
Modified on Fri Sep 20 14:57:54 2024 by modify_doxy.py rev. 669887