added convenience macros

This commit is contained in:
Matej Sekoranja
2011-01-02 10:47:08 +01:00
parent 3f9852bd58
commit 7d9b5ce725

View File

@@ -49,5 +49,50 @@ private:
extern ShowConstructDestruct* getShowConstructDestruct();
/* convenience macros - no getTotalReferenceCount() support */
#define PVDATA_REFCOUNT_MONITOR_DEFINE(NAME) \
static volatile int64 NAME ## _totalConstruct = 0; \
static volatile int64 NAME ## _totalDestruct = 0; \
static Mutex * NAME ## _globalMutex = 0; \
\
static int64 NAME ## _processTotalConstruct() \
{ \
Lock xx(NAME ## _globalMutex); \
return NAME ## _totalConstruct; \
} \
\
static int64 NAME ## _processTotalDestruct() \
{ \
Lock xx(NAME ## _globalMutex); \
return NAME ## _totalDestruct; \
} \
\
static ConstructDestructCallback * NAME ## _pConstructDestructCallback; \
\
static void NAME ## _init() \
{ \
static Mutex mutex = Mutex(); \
Lock xx(&mutex); \
if(NAME ## _globalMutex==0) { \
NAME ## _globalMutex = new Mutex(); \
NAME ## _pConstructDestructCallback = new ConstructDestructCallback( \
String(#NAME), \
NAME ## _processTotalConstruct,NAME ## _processTotalDestruct,0); \
} \
}
#define PVDATA_REFCOUNT_MONITOR_DESTRUCT(NAME) \
Lock xx(NAME ## _globalMutex); \
NAME ## _totalDestruct++;
#define PVDATA_REFCOUNT_MONITOR_CONSTRUCT(NAME) \
NAME ## _init(); \
Lock xx(NAME ## _globalMutex); \
NAME ## _totalConstruct++;
}}
#endif /* SHOWCONSTRUCTDESTRUCT_H */