A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/ncbi__safe__static_8hpp_source.html below:

NCBI C++ ToolKit: include/corelib/ncbi_safe_static.hpp Source File

1 #ifndef NCBI_SAFE_STATIC__HPP 2 #define NCBI_SAFE_STATIC__HPP 76

eLifeSpan_Shortest = -20000,

77

eLifeSpan_Short = -10000,

79

eLifeSpan_Long = 10000,

80

eLifeSpan_Longest = 20000

119  typedef

void (*FUserCleanup)(

void

* ptr);

146

FUserCleanup user_cleanup = 0,

147  TLifeSpan

life_span = TLifeSpan::GetDefault())

148

: m_SelfCleanup(self_cleanup),

149

m_UserCleanup(user_cleanup),

150

m_LifeSpan(life_span),

151

m_CreationOrder(x_GetCreationOrder()),

163  return

m_Ptr.load(memory_order_acquire);

166

m_Ptr.store(ptr, memory_order_release);

169  return

x_GetPtr() !=

nullptr

;

172  if

(

auto

ptr = x_GetPtr() ) {

188  if

(!m_InstanceMutex || !m_MutexRefCount) {

189

m_InstanceMutex =

new CMutex

;

194

m_InstanceMutex->Lock();

199

m_InstanceMutex->Unlock();

200

x_ReleaseInstanceMutex();

206  if

(--m_MutexRefCount > 0)

return

;

226  static int

x_GetCreationOrder(

void

);

241  if

( m_SelfCleanup ) {

243

m_SelfCleanup(

this

, guard);

246

x_ReleaseInstanceMutex();

305  if

(stack) stack->insert(ptr);

312  static void

DisableChildThreadsCheck();

329  const size_t

index = level;

331  _ASSERT

(index < stacks.size());

332  return

stacks[index];

336  static void

x_Cleanup(

CMutexGuard

& guard, TStack*& stack);

370  if

(ptr)

delete static_cast<T

*

>

(ptr);

374  if

(ptr)

delete const_cast<T

*

>

(

static_cast<const T

*

>

(ptr));

399  typedef T

* (*FCreate)(void);

461  return static_cast<T

*

>

(

const_cast<void

*

>

(ptr));

550  "CSafeStatic::Init: Register() failed"

);

574 template

<

class

T,

class

V, V value>

585 #define SAFE_CONST_STATIC(type, init_value) \ 586  SAFE_CONST_STATIC_EX(type, type, init_value) 590 #define SAFE_CONST_STATIC_EX(type, init_value_type, init_value) \ 591  CSafeStatic< const type, \ 592  CSafeStaticInit_Callbacks<const type, init_value_type, init_value> > 595 #define SAFE_CONST_STATIC_STRING(var, value) \ 596  char SAFE_CONST_STATIC_STRING_##var[] = value; \ 597  SAFE_CONST_STATIC_EX(std::string, const char*, \ 598  SAFE_CONST_STATIC_STRING_##var) var 617  return static_cast<T

*

>

(

const_cast<void

*

>

(ptr));

645  template

<

class

FUserCreate>

647  T

&

Get

(FUserCreate user_create)

662  void Set

(

T

*

object

);

668  template

<

class

FUserCreate>

669  void x_Init

(FUserCreate user_create);

679  if

( user_cleanup ) {

703  return static_cast<T

*

>

(

const_cast<void

*

>

(ptr));

731  template

<

class

FUserCreate>

733  T

&

Get

(FUserCreate user_create)

753  template

<

class

FUserCreate>

764  if

( user_cleanup ) {

767

ptr->RemoveReference();

791  if

( !x_IsSetPtr() ) {

806  if

( !x_IsSetPtr() ) {

815 template

<

class

FUserCreate>

820  if

( !x_IsSetPtr() ) {

822  if

(

auto

ptr = user_create() ) {

835  if

( !x_IsSetPtr() ) {

838  object

->AddReference();

851  if

( !x_IsSetPtr() ) {

862 template

<

class

FUserCreate>

867  if

( !x_IsSetPtr() ) {

869  T

* ptr = user_create();

void Release()

Manually force the resource to be released.

static void Register(CSafeStaticPtr_Base *ptr)

Add new on-demand variable to the cleanup stack.

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

static bool sm_ChildThreadsCheck

multiset< CSafeStaticPtr_Base *, CSafeStatic_Less > TStack

Safe static callbacks version allowing initial value of type V.

ELifeLevel GetLifeLevel() const

Get life level value.

static CSafeStaticLifeSpan & GetDefault(void)

Get default life span (set to eLifeSpan_Min).

int GetLifeSpan(void) const

Get life span value.

ELifeSpan

Predefined life spans for the safe static objects.

@ eLifeSpan_Min

std static, not adjustable

ELifeLevel

Predefined life levels for the safe static objects.

DECLARE_CLASS_STATIC_MUTEX(sm_ClassMutex)

void(* FUserCleanup)(void *ptr)

User cleanup function type.

const void * x_GetPtr() const

static int x_GetCreationOrder(void)

CGuard< CSafeStaticPtr_Base > TInstanceMutexGuard

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

Constructor.

FUserCleanup m_UserCleanup

CSafeStaticLifeSpan TLifeSpan

Life span.

void x_ReleaseInstanceMutex(void)

bool x_IsStdStatic(void) const

atomic< const void * > m_Ptr

Pointer to the data.

FSelfCleanup m_SelfCleanup

void x_SetPtr(const void *ptr)

const void * x_ReleasePtr()

static void sx_SelfCleanup(CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard)

CSafeStaticLifeSpan TLifeSpan

static T * x_CastPtr(const void *ptr)

T & Get(FUserCreate user_create)

Get the existing object or create a new one using the provided FUserCreate object.

void Set(T *object)

Initialize with an existing object.

CSafeStaticPtr(FUserCleanup user_cleanup=0, TLifeSpan life_span=TLifeSpan::GetDefault())

Constructor.

T & Get(void)

Create the variable if not created yet, return the reference.

T & Get(void)

Create the variable if not created yet, return the reference.

static void sx_SelfCleanup(CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard)

void x_Init(FUserCreate user_create)

static T * x_CastPtr(const void *ptr)

void Set(T *object)

Initialize with an existing object.

T & Get(FUserCreate user_create)

Get the existing object or create a new one using the provided FUserCreate object.

CSafeStaticLifeSpan TLifeSpan

CSafeStaticRef(FUserCleanup user_cleanup=0, TLifeSpan life_span=TLifeSpan::GetDefault())

Constructor.

Helper class for object allocation/deallocation.

static void s_RemoveReference(CObject *ptr)

static void s_RemoveReference(const CObject *ptr)

static void s_RemoveReference(const void *ptr)

static void s_AddReference(const void *)

static void s_AddReference(void *)

static void s_RemoveReference(void *ptr)

static void s_AddReference(CObject *ptr)

static T * s_Create(void)

Create a new class instance.

Initialization and cleanup of a safe-static object.

CSafeStatic_Callbacks(FCreate create=0, FCleanup cleanup=0)

The constructor allows to use CSafeStatic_Callbacks as a simple wrapper for static functions.

void Cleanup(T &value)

Perform cleanup before destruction.

T * Create(void)

Create new object.

void(* FCleanup)(T &value)

T *(* FCreate)(void)

The default implementation allows to use callback functions rather than a new class.

CSafeStatic_Allocator< T > TAllocator

Comparison for safe static ptrs.

bool operator()(const TPtr &ptr1, const TPtr &ptr2) const

CSafeStaticPtr_Base * TPtr

CSafeStatic_Callbacks< T >::FCreate FCreate

Callback function types.

CSafeStatic_Allocator< T > TAllocator

CSafeStatic & operator=(const CSafeStatic &)=delete

CSafeStatic(FCreate create, FCleanup cleanup, TLifeSpan life_span=TLifeSpan::GetDefault())

Constructor.

static void sx_SelfCleanup(CSafeStaticPtr_Base *safe_static, TInstanceMutexGuard &guard)

CSafeStaticLifeSpan TLifeSpan

T & Get(void)

Create the variable if not created yet, return the reference.

CSafeStatic(const CSafeStatic &)=delete

CSafeStatic(TLifeSpan life_span=TLifeSpan::GetDefault())

Constructor.

CSafeStatic< T, TCallbacks > TThisType

CSafeStatic_Callbacks< T >::FCleanup FCleanup

static T * x_CastPtr(const void *ptr)

CSafeStatic(TCallbacks callbacks, TLifeSpan life_span=TLifeSpan::GetDefault())

Constructor.

static void cleanup(void)

#define NCBI_THROW(exception_class, err_code, message)

Generic macro to throw an exception, given the exception class, error code and message string.

#define NCBI_RETHROW_SAME(prev_exception, message)

Generic macro to re-throw the same exception.

void AddReference(void) const

Add reference to object.

void RemoveReference(void) const

Remove reference to object.

#define END_NCBI_SCOPE

End previously defined NCBI scope.

#define BEGIN_NCBI_SCOPE

Define ncbi namespace.

void Cleanup(CTls< TValue > &value)

#define NCBI_XNCBI_EXPORT

unsigned int

A callback function used to compare two keys in a database.

const GenericPointer< typename T::ValueType > T2 value

static CSafeStaticGuard s_CleanupGuard

This static variable must be present in all modules using on-demand static variables.

Multi-threading – mutexes; rw-locks; semaphore.

Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.

SSimpleLock is a functor to wrap calling Lock().

SSimpleLock is a functor to wrap calling Unlock().


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4