NCBI C++ ToolKit
|
Search Toolkit Book for CSafeStaticGuard
#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_Less > | TStack |
Static Private Member Functions | |
static CSafeStaticGuard * | x_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 |
Register all on-demand variables, destroy them on the program termination.
Definition at line 273 of file ncbi_safe_static.hpp.
|
private |
Definition at line 311 of file ncbi_safe_static.hpp.
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 | ( | void | ) |
Check reference count, and if it is zero, then destroy all registered variables.
Definition at line 161 of file ncbi_safe_static.cpp.
References _ASSERT, assert, CSafeStaticLifeSpan::eLifeLevel_AppMain, CSafeStaticLifeSpan::eLifeLevel_Default, ERR_POST_X, Error(), CThread::GetThreadsCount(), msg(), sh_CleanupGuard, sm_ChildThreadsCheck, sm_RefCount, tmp, x_Cleanup(), and x_GetStack().
|
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().
|
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().
|
inlinestatic |
Add new on-demand variable to the cleanup stack.
Definition at line 285 of file ncbi_safe_static.hpp.
References CSafeStaticLifeSpan::GetLifeLevel(), CSafeStaticPtr_Base::m_LifeSpan, sm_RefCount, x_Get(), x_GetStack(), and CSafeStaticPtr_Base::x_IsStdStatic().
Referenced by CSafeStaticPtr< T >::Set(), CSafeStaticRef< T >::Set(), CSafeStatic< CTls< TValue >, CStaticTls_Callbacks< TValue > >::x_Init(), CSafeStaticPtr< T >::x_Init(), and CSafeStaticRef< T >::x_Init().
|
staticprivate |
Definition at line 190 of file ncbi_safe_static.cpp.
References CGuard< Resource, Lock, Unlock, ReportExceptions >::Guard(), NON_CONST_ITERATE, CGuard< Resource, Lock, Unlock, ReportExceptions >::Release(), and swap().
Referenced by Destroy(), and ~CSafeStaticGuard().
|
staticprivate |
Definition at line 216 of file ncbi_safe_static.cpp.
References CSafeStaticGuard(), and sh_CleanupGuard.
Referenced by Register().
|
inlinestaticprivate |
Definition at line 314 of file ncbi_safe_static.hpp.
References _ASSERT.
Referenced by CSafeStaticGuard(), Destroy(), Register(), and ~CSafeStaticGuard().
Definition at line 332 of file ncbi_safe_static.hpp.
Referenced by DisableChildThreadsCheck(), and ~CSafeStaticGuard().
|
staticprivate |
Definition at line 329 of file ncbi_safe_static.hpp.
Referenced by CSafeStaticGuard(), Register(), and ~CSafeStaticGuard().