This is Unofficial EPICS BASE Doxygen Site
SingletonUntyped Class Reference

#include "epicsSingleton.h"

Public Types

typedef void *(* PBuild) ()
 
typedef void(* PDestroy) (void *)
 

Public Member Functions

 SingletonUntyped ()
 
 ~SingletonUntyped ()
 
void incrRefCount (PBuild)
 
void decrRefCount (PDestroy)
 
void * pInstance () const
 

Detailed Description

Definition at line 24 of file epicsSingleton.h.

Member Typedef Documentation

typedef void*( * SingletonUntyped::PBuild) ()

Definition at line 28 of file epicsSingleton.h.

typedef void( * SingletonUntyped::PDestroy) (void *)

Definition at line 30 of file epicsSingleton.h.

Constructor & Destructor Documentation

SingletonUntyped::SingletonUntyped ( )
inline

Definition at line 159 of file epicsSingleton.h.

159  :
160  _pInstance ( 0 ), _refCount ( 0 )
161 {
162 }
SingletonUntyped::~SingletonUntyped ( )
inline

Definition at line 169 of file epicsSingleton.h.

170 {
171  // we dont assert fail on non-zero _refCount
172  // and or non nill _pInstance here because this
173  // is designed to tolarate situations where
174  // file scope epicsSingleton objects (which
175  // theoretically dont have storage lifespan
176  // issues) are deleted in a non-determanistic
177  // order
178 # if 0
179  assert ( _refCount == 0 );
180  assert ( _pInstance == 0 );
181 # endif
182 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70

Member Function Documentation

void SingletonUntyped::decrRefCount ( PDestroy  pDestroy)

Definition at line 49 of file epicsSingletonMutex.cpp.

50 {
52  guard ( *pEPICSSigletonMutex );
53  assert ( _refCount > 0 );
54  _refCount--;
55  if ( _refCount == 0 ) {
56  ( *pDestroy ) ( _pInstance );
57  _pInstance = 0;
58  }
59 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
void SingletonUntyped::incrRefCount ( PBuild  pBuild)

Definition at line 37 of file epicsSingletonMutex.cpp.

38 {
39  epicsThreadOnce ( & epicsSigletonOnceFlag, SingletonMutexOnce, 0 );
41  guard ( *pEPICSSigletonMutex );
42  assert ( _refCount < SIZE_MAX );
43  if ( _refCount == 0 ) {
44  _pInstance = ( * pBuild ) ();
45  }
46  _refCount++;
47 }
#define assert(exp)
Declare that a condition should be true.
Definition: epicsAssert.h:70
#define SIZE_MAX
void SingletonMutexOnce(void *)
LIBCOM_API void epicsStdCall epicsThreadOnce(epicsThreadOnceId *id, EPICSTHREADFUNC, void *arg)
void * SingletonUntyped::pInstance ( ) const
inline

Definition at line 164 of file epicsSingleton.h.

165 {
166  return _pInstance;
167 }

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