switch remaining to use REFCOUNT macros
This commit is contained in:
@@ -35,52 +35,18 @@ public :
|
||||
FieldPvt::FieldPvt(String fieldName,Type type)
|
||||
: fieldName(fieldName),type(type),referenceCount(1) { }
|
||||
|
||||
static volatile int64 totalReferenceCount = 0;
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalReferenceCount()
|
||||
{
|
||||
return totalReferenceCount;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("field"),
|
||||
getTotalConstruct,getTotalDestruct,getTotalReferenceCount,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(field);
|
||||
|
||||
static Mutex refCountMutex;
|
||||
|
||||
Field::Field(String fieldName,Type type)
|
||||
: pImpl(new FieldPvt(fieldName,type))
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(field);
|
||||
}
|
||||
|
||||
Field::~Field() {
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(field);
|
||||
// note that compiler automatically calls destructor for fieldName
|
||||
if(debugLevel==highDebug) printf("~Field %s\n",pImpl->fieldName.c_str());
|
||||
delete pImpl;
|
||||
@@ -88,7 +54,7 @@ Field::~Field() {
|
||||
}
|
||||
|
||||
int Field::getReferenceCount() const {
|
||||
Lock xx(&globalMutex);
|
||||
Lock xx(&refCountMutex);
|
||||
return pImpl->referenceCount;
|
||||
}
|
||||
|
||||
@@ -102,9 +68,9 @@ void Field::renameField(String newName)
|
||||
}
|
||||
|
||||
void Field::incReferenceCount() const {
|
||||
Lock xx(&globalMutex);
|
||||
field_node.incRef();
|
||||
Lock xx(&refCountMutex);
|
||||
pImpl->referenceCount++;
|
||||
totalReferenceCount++;
|
||||
if(pImpl->type!=structure) return;
|
||||
StructureConstPtr structure = static_cast<StructureConstPtr>(this);
|
||||
FieldConstPtrArray fields = structure->getFields();
|
||||
@@ -115,14 +81,14 @@ void Field::incReferenceCount() const {
|
||||
}
|
||||
|
||||
void Field::decReferenceCount() const {
|
||||
Lock xx(&globalMutex);
|
||||
field_node.decRef();
|
||||
Lock xx(&refCountMutex);
|
||||
if(pImpl->referenceCount<=0) {
|
||||
String message("logicError field ");
|
||||
message += pImpl->fieldName;
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
pImpl->referenceCount--;
|
||||
totalReferenceCount--;
|
||||
if(pImpl->type!=structure) {
|
||||
if(pImpl->referenceCount==0) {
|
||||
delete this;
|
||||
@@ -435,7 +401,6 @@ static FieldCreate* fieldCreate = 0;
|
||||
|
||||
FieldCreate::FieldCreate()
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
FieldCreate * getFieldCreate() {
|
||||
|
||||
@@ -17,34 +17,7 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("pvAuxInfo"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(pvAuxInfo);
|
||||
|
||||
typedef std::map<String,PVScalar * >::const_iterator map_iterator;
|
||||
|
||||
@@ -61,14 +34,11 @@ public:
|
||||
PVAuxInfo::PVAuxInfo(PVField *pvField)
|
||||
: pImpl(new PVAuxInfoPvt(pvField))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(pvAuxInfo);
|
||||
}
|
||||
|
||||
PVAuxInfo::~PVAuxInfo() {
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(pvAuxInfo);
|
||||
map_iterator i = pImpl->theMap.begin();
|
||||
while(i!=pImpl->theMap.end()) {
|
||||
PVScalar *value = i->second;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
#include "lock.h"
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "showConstructDestruct.h"
|
||||
@@ -16,33 +17,7 @@ namespace epics { namespace pvData {
|
||||
|
||||
static String notImplemented("not implemented");
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("pvField"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(pvField);
|
||||
|
||||
class PVFieldPvt {
|
||||
public:
|
||||
@@ -77,15 +52,12 @@ PVFieldPvt::~PVFieldPvt()
|
||||
PVField::PVField(PVStructure *parent,FieldConstPtr field)
|
||||
: pImpl(new PVFieldPvt(parent,field))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(pvField);
|
||||
}
|
||||
|
||||
PVField::~PVField()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(pvField);
|
||||
delete pImpl;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,33 +19,7 @@ namespace epics { namespace pvData {
|
||||
|
||||
//static DebugLevel debugLevel = lowDebug;
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("status"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(status);
|
||||
|
||||
class StatusImpl : public Status
|
||||
{
|
||||
@@ -54,20 +28,17 @@ class StatusImpl : public Status
|
||||
StatusImpl(StatusType type, String message) :
|
||||
m_type(type), m_message(message)
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(status);
|
||||
}
|
||||
|
||||
StatusImpl(StatusType type, String message, String stackDump) :
|
||||
m_type(type), m_message(message), m_stackDump(stackDump)
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(status);
|
||||
}
|
||||
|
||||
virtual ~StatusImpl() {
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(status);
|
||||
}
|
||||
|
||||
virtual StatusType getType()
|
||||
@@ -158,7 +129,6 @@ class StatusCreateImpl : public StatusCreate {
|
||||
|
||||
StatusCreateImpl()
|
||||
{
|
||||
init();
|
||||
m_ok = createStatus(STATUSTYPE_OK, "OK", 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,56 +15,24 @@ namespace epics { namespace pvData {
|
||||
|
||||
//static DebugLevel debugLevel = lowDebug;
|
||||
|
||||
static Mutex globalMutex;
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("bitSet"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(bitSet);
|
||||
|
||||
BitSet::BitSet() : words(0), wordsLength(0), wordsInUse(0) {
|
||||
initWords(BITS_PER_WORD);
|
||||
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(bitSet);
|
||||
}
|
||||
|
||||
BitSet::BitSet(uint32 nbits) : words(0), wordsLength(0), wordsInUse(0) {
|
||||
initWords(nbits);
|
||||
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(bitSet);
|
||||
}
|
||||
|
||||
BitSet::~BitSet() {
|
||||
delete[] words;
|
||||
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(bitSet);
|
||||
}
|
||||
|
||||
void BitSet::initWords(uint32 nbits) {
|
||||
|
||||
@@ -24,50 +24,20 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static Mutex globalMutex;
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static bool notInited = true;
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(event);
|
||||
static String alreadyOn("already on list");
|
||||
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("event"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
epicsEventDestroy(id);
|
||||
id = 0;
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(event);
|
||||
}
|
||||
|
||||
|
||||
Event::Event(bool full)
|
||||
: id(epicsEventCreate(full?epicsEventFull : epicsEventEmpty))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(event);
|
||||
}
|
||||
|
||||
void Event::signal()
|
||||
|
||||
@@ -21,33 +21,7 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static void init() {
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("executor"),
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(executor);
|
||||
|
||||
typedef LinkedListNode<ExecutorNode> ExecutorListNode;
|
||||
typedef LinkedList<ExecutorNode> ExecutorList;
|
||||
@@ -149,15 +123,12 @@ void ExecutorPvt::execute(ExecutorNode *node)
|
||||
Executor::Executor(String threadName,ThreadPriority priority)
|
||||
: pImpl(new ExecutorPvt(threadName,priority))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(executor);
|
||||
}
|
||||
|
||||
Executor::~Executor() {
|
||||
delete pImpl;
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(executor);
|
||||
}
|
||||
|
||||
ExecutorNode * Executor::createNode(Command*command)
|
||||
|
||||
@@ -18,76 +18,27 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static Mutex globalMutex;
|
||||
static String alreadyOnList("already on list");
|
||||
|
||||
static volatile int64 totalNodeConstruct = 0;
|
||||
static volatile int64 totalNodeDestruct = 0;
|
||||
static volatile int64 totalListConstruct = 0;
|
||||
static volatile int64 totalListDestruct = 0;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalNodeConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalNodeDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalListConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalListDestruct;
|
||||
}
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"linkedListNode",
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0,0);
|
||||
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"linkedList",
|
||||
getTotalListConstruct,getTotalListDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(LinkedListNode);
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(LinkedList);
|
||||
|
||||
LinkedListVoidNode::LinkedListVoidNode(void *object)
|
||||
: object(object),before(0),after(0),linkedListVoid(0)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(LinkedListNode);
|
||||
}
|
||||
|
||||
LinkedListVoidNode::LinkedListVoidNode(bool isHead)
|
||||
: object(this),before(this),after(this)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(LinkedListNode);
|
||||
}
|
||||
|
||||
|
||||
LinkedListVoidNode::~LinkedListVoidNode()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(LinkedListNode);
|
||||
}
|
||||
|
||||
void *LinkedListVoidNode::getObject() {
|
||||
@@ -103,16 +54,13 @@ bool LinkedListVoidNode::isOnList()
|
||||
LinkedListVoid::LinkedListVoid()
|
||||
: head(new LinkedListVoidNode(true)),length(0)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalListConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(LinkedList);
|
||||
}
|
||||
|
||||
LinkedListVoid::~LinkedListVoid()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
delete head;
|
||||
totalListDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(LinkedList);
|
||||
}
|
||||
|
||||
int LinkedListVoid::getLength()
|
||||
|
||||
@@ -21,33 +21,7 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalQueueConstruct = 0;
|
||||
static volatile int64 totalQueueDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalQueueConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalQueueDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueDestruct;
|
||||
}
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"messageQueue",
|
||||
getTotalQueueConstruct,getTotalQueueDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(messageQueue);
|
||||
|
||||
typedef MessageNode * MessageNodePtr;
|
||||
typedef QueueElement<MessageNode> MessageElement;
|
||||
@@ -79,9 +53,7 @@ public:
|
||||
MessageQueue::MessageQueue(int size)
|
||||
: pImpl(new MessageQueuePvt)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(messageQueue);
|
||||
pImpl->size = size;
|
||||
pImpl->overrun = 0;
|
||||
pImpl->lastPut = 0;
|
||||
@@ -100,8 +72,7 @@ MessageQueue::~MessageQueue()
|
||||
delete pImpl->messageNodeArray[i];
|
||||
}
|
||||
delete[] pImpl->messageNodeArray;
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(messageQueue);
|
||||
}
|
||||
|
||||
MessageNode *MessageQueue::get() {
|
||||
|
||||
@@ -18,65 +18,19 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalElementConstruct = 0;
|
||||
static volatile int64 totalElementDestruct = 0;
|
||||
static volatile int64 totalQueueConstruct = 0;
|
||||
static volatile int64 totalQueueDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalNodeConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalElementConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalNodeDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalElementDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueDestruct;
|
||||
}
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"queueElement",
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0,0);
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"queue",
|
||||
getTotalListConstruct,getTotalListDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(queueElement);
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(queue);
|
||||
|
||||
QueueElementVoid::QueueElementVoid(ObjectPtr object)
|
||||
: object(object)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalElementConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(queueElement);
|
||||
}
|
||||
|
||||
|
||||
QueueElementVoid::~QueueElementVoid()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
totalElementDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(queueElement);
|
||||
}
|
||||
|
||||
ObjectPtr QueueElementVoid::getObject() {
|
||||
@@ -94,9 +48,7 @@ QueueVoid::QueueVoid(ObjectPtr object[],int number)
|
||||
for(int i=0; i<number; i++) {
|
||||
array[i] = new QueueElementVoid(object[i]);
|
||||
}
|
||||
initPvt();
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(queue);
|
||||
}
|
||||
|
||||
QueueVoid::~QueueVoid()
|
||||
@@ -105,8 +57,7 @@ QueueVoid::~QueueVoid()
|
||||
delete array[i];
|
||||
}
|
||||
delete[]array;
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(queue);
|
||||
}
|
||||
|
||||
void QueueVoid::clear()
|
||||
|
||||
@@ -23,51 +23,8 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
|
||||
static volatile int64 totalNodeConstruct = 0;
|
||||
static volatile int64 totalNodeDestruct = 0;
|
||||
static volatile int64 totalTimerConstruct = 0;
|
||||
static volatile int64 totalTimerDestruct = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalTimerNodeConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerNodeDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerConstruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalTimerConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerDestruct()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
return totalTimerDestruct;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"timerNode",
|
||||
getTotalTimerNodeConstruct,getTotalTimerNodeDestruct,0,0);
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"timer",
|
||||
getTotalTimerConstruct,getTotalTimerDestruct,0,0);
|
||||
}
|
||||
}
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(timerNode);
|
||||
PVDATA_REFCOUNT_MONITOR_DEFINE(timer);
|
||||
|
||||
class TimerNodePvt;
|
||||
|
||||
@@ -154,9 +111,7 @@ static void addElement(TimerPvt *timer,TimerNodePvt *node)
|
||||
TimerNode::TimerNode(TimerCallback *callback)
|
||||
: pImpl(new TimerNodePvt(this,callback))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(timerNode);
|
||||
}
|
||||
|
||||
|
||||
@@ -164,8 +119,7 @@ TimerNode::~TimerNode()
|
||||
{
|
||||
cancel();
|
||||
delete pImpl;
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(timerNode);
|
||||
}
|
||||
|
||||
void TimerNode::cancel()
|
||||
@@ -240,9 +194,7 @@ void TimerPvt::run()
|
||||
Timer::Timer(String threadName, ThreadPriority priority)
|
||||
: pImpl(new TimerPvt(threadName,priority))
|
||||
{
|
||||
init();
|
||||
Lock xx(&globalMutex);
|
||||
totalTimerConstruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_CONSTRUCT(timer);
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
@@ -258,8 +210,7 @@ Timer::~Timer() {
|
||||
node->getObject()->callback->timerStopped();
|
||||
}
|
||||
delete pImpl;
|
||||
Lock xx(&globalMutex);
|
||||
totalTimerDestruct++;
|
||||
PVDATA_REFCOUNT_MONITOR_DESTRUCT(timer);
|
||||
}
|
||||
|
||||
void Timer::scheduleAfterDelay(TimerNode *timerNode,double delay)
|
||||
|
||||
Reference in New Issue
Block a user