Fix many memory leaks
This commit is contained in:
+662
-673
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -28,11 +28,11 @@ INC += messageQueue.h
|
||||
INC += destroyable.h
|
||||
INC += status.h
|
||||
|
||||
LIBSRCS += showConstructDestruct.cpp
|
||||
LIBSRCS += byteBuffer.cpp
|
||||
LIBSRCS += bitSet.cpp
|
||||
LIBSRCS += requester.cpp
|
||||
LIBSRCS += serializeHelper.cpp
|
||||
LIBSRCS += showConstructDestruct.cpp
|
||||
LIBSRCS += linkedListVoid.cpp
|
||||
LIBSRCS += event.cpp
|
||||
LIBSRCS += thread.cpp
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -19,31 +20,29 @@ static String notImplemented("not implemented");
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("pvField"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +66,12 @@ PVFieldPvt::PVFieldPvt(PVStructure *parent,FieldConstPtr field)
|
||||
pvAuxInfo(0),
|
||||
immutable(false),requester(0),postHandler(0)
|
||||
{
|
||||
field->incReferenceCount();
|
||||
}
|
||||
|
||||
PVFieldPvt::~PVFieldPvt()
|
||||
{
|
||||
if(pvAuxInfo!=0) delete pvAuxInfo;
|
||||
field->decReferenceCount();
|
||||
if(pvAuxInfo!=0) delete pvAuxInfo;
|
||||
if(parent==0) field->decReferenceCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,24 +80,17 @@ PVField::PVField(PVStructure *parent,FieldConstPtr field)
|
||||
: pImpl(new PVFieldPvt(parent,field))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
PVField::~PVField()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
delete pImpl;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *PVField::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pConstructDestructCallback;
|
||||
}
|
||||
|
||||
|
||||
String PVField::getRequesterName()
|
||||
{
|
||||
static String none("none");
|
||||
@@ -322,18 +313,22 @@ void PVField::computeOffset(PVField * pvField,int offset) {
|
||||
|
||||
void PVField::replaceStructure(PVStructure *pvStructure,int length)
|
||||
{
|
||||
PVFieldPtrArray pvFields = pvStructure->getPVFields();
|
||||
FieldConstPtrArray newFields = new FieldConstPtr[length];
|
||||
for(int i=0; i<length; i++) {
|
||||
newFields[i] = pvFields[i]->getField();
|
||||
}
|
||||
StructureConstPtr newStructure = getFieldCreate()->createStructure(
|
||||
pImpl->field->getFieldName(),length, newFields);
|
||||
pImpl->field = newStructure;
|
||||
PVStructure *parent = pImpl->parent;
|
||||
if(parent!=0) {
|
||||
parent->replaceStructure(parent,parent->getStructure()->getNumberFields());
|
||||
}
|
||||
PVFieldPtrArray pvFields = pvStructure->getPVFields();
|
||||
FieldConstPtrArray newFields = new FieldConstPtr[length];
|
||||
for(int i=0; i<length; i++) {
|
||||
newFields[i] = pvFields[i]->getField();
|
||||
}
|
||||
StructureConstPtr newStructure = getFieldCreate()->createStructure(
|
||||
pImpl->field->getFieldName(),length, newFields);
|
||||
PVStructure *parent = pImpl->parent;
|
||||
if(parent==0) {
|
||||
pImpl->field->decReferenceCount();
|
||||
}
|
||||
pImpl->field = newStructure;
|
||||
if(parent!=0) {
|
||||
parent->replaceStructure(
|
||||
parent,parent->getStructure()->getNumberFields());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,22 +54,17 @@ namespace epics { namespace pvData {
|
||||
switch(field->getType()) {
|
||||
case scalar: {
|
||||
ScalarConstPtr scalar = (ScalarConstPtr)field;
|
||||
pvFields[i] = pvDataCreate->createPVScalar(this,
|
||||
field->getFieldName(),scalar->getScalarType());
|
||||
pvFields[i] = pvDataCreate->createPVScalar(this,scalar);
|
||||
break;
|
||||
}
|
||||
case scalarArray: {
|
||||
ScalarArrayConstPtr array = (ScalarArrayConstPtr)field;
|
||||
ScalarType elementType = array->getElementType();
|
||||
pvFields[i] = pvDataCreate->createPVScalarArray(this,
|
||||
field->getFieldName(),elementType);
|
||||
pvFields[i] = pvDataCreate->createPVScalarArray(this,array);
|
||||
break;
|
||||
}
|
||||
case structure: {
|
||||
StructureConstPtr structPtr = (StructureConstPtr)field;
|
||||
int numberFields = structPtr->getNumberFields();
|
||||
pvFields[i] = pvDataCreate->createPVStructure(this,
|
||||
field->getFieldName(), numberFields,structPtr->getFields());
|
||||
pvFields[i] = pvDataCreate->createPVStructure(this, structPtr);
|
||||
break;
|
||||
}
|
||||
case structureArray: {
|
||||
|
||||
@@ -57,16 +57,16 @@ namespace epics { namespace pvData {
|
||||
structureArrayData(new StructureArrayData()),
|
||||
value(new PVStructurePtr[0])
|
||||
{
|
||||
structureArray->incReferenceCount();
|
||||
}
|
||||
|
||||
BasePVStructureArray::~BasePVStructureArray()
|
||||
{
|
||||
structureArray->decReferenceCount();
|
||||
delete structureArrayData;
|
||||
int length = getLength();
|
||||
for(int i=0; i<length; i++) {
|
||||
if(value[i]!=0) delete value[i];
|
||||
if(value[i]!=0) {
|
||||
delete value[i];
|
||||
}
|
||||
}
|
||||
delete[] value;
|
||||
}
|
||||
@@ -135,6 +135,7 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
StructureConstPtr structure = structureArray->getStructure();
|
||||
for(int i=0; i<len; i++) {
|
||||
if(value[i+offset]!=0) delete value[i+offset];
|
||||
PVStructurePtr frompv = from[i+fromOffset];
|
||||
if(frompv==0) {
|
||||
value[i+offset] = 0;
|
||||
@@ -151,9 +152,13 @@ namespace epics { namespace pvData {
|
||||
}
|
||||
|
||||
void BasePVStructureArray::shareData(
|
||||
PVStructurePtrArray value,int capacity,int length)
|
||||
PVStructurePtrArray newValue,int capacity,int length)
|
||||
{
|
||||
this->value = value;
|
||||
for(int i=0; i<getLength(); i++) {
|
||||
if(value[i]!=0) delete value[i];
|
||||
}
|
||||
delete[] value;
|
||||
value = newValue;
|
||||
setCapacity(capacity);
|
||||
setLength(length);
|
||||
}
|
||||
|
||||
@@ -3665,7 +3665,7 @@ public:
|
||||
};
|
||||
|
||||
Convert * getConvert() {
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
|
||||
if(convert==0){
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
#include <cstdio>
|
||||
#include <lock.h>
|
||||
#include "pvIntrospect.h"
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -27,26 +29,27 @@ public :
|
||||
FieldPvt(String fieldName,Type type);
|
||||
String fieldName;
|
||||
Type type;
|
||||
mutable volatile int referenceCount;
|
||||
int referenceCount;
|
||||
};
|
||||
|
||||
FieldPvt::FieldPvt(String fieldName,Type type)
|
||||
: fieldName(fieldName),type(type),referenceCount(0) { }
|
||||
: fieldName(fieldName),type(type),referenceCount(1) { }
|
||||
|
||||
static volatile int64 totalReferenceCount = 0;
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
@@ -55,17 +58,15 @@ static int64 getTotalReferenceCount()
|
||||
return totalReferenceCount;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("field"),
|
||||
getTotalConstruct,getTotalDestruct,getTotalReferenceCount);
|
||||
getTotalConstruct,getTotalDestruct,getTotalReferenceCount,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,20 +74,21 @@ static void init()
|
||||
Field::Field(String fieldName,Type type)
|
||||
: pImpl(new FieldPvt(fieldName,type))
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
Field::~Field() {
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
// note that compiler automatically calls destructor for fieldName
|
||||
delete pImpl;
|
||||
if(debugLevel==highDebug) printf("~Field %s\n",pImpl->fieldName.c_str());
|
||||
delete pImpl;
|
||||
pImpl = 0;
|
||||
}
|
||||
|
||||
int Field::getReferenceCount() const {
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return pImpl->referenceCount;
|
||||
}
|
||||
|
||||
@@ -95,23 +97,59 @@ String Field::getFieldName() const {return pImpl->fieldName;}
|
||||
Type Field::getType() const {return pImpl->type;}
|
||||
|
||||
void Field::incReferenceCount() const {
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
pImpl->referenceCount++;
|
||||
totalReferenceCount++;
|
||||
if(pImpl->type!=structure) return;
|
||||
StructureConstPtr structure = static_cast<StructureConstPtr>(this);
|
||||
FieldConstPtrArray fields = structure->getFields();
|
||||
int numberFields = structure->getNumberFields();
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
fields[i]->incReferenceCount();
|
||||
}
|
||||
}
|
||||
|
||||
void Field::decReferenceCount() const {
|
||||
Lock xx(globalMutex);
|
||||
if(pImpl->referenceCount<=0) {
|
||||
Lock xx(&globalMutex);
|
||||
if(pImpl->referenceCount<=0) {
|
||||
String message("logicError field ");
|
||||
message += pImpl->fieldName;
|
||||
throw std::logic_error(message);
|
||||
}
|
||||
pImpl->referenceCount--;
|
||||
}
|
||||
pImpl->referenceCount--;
|
||||
totalReferenceCount--;
|
||||
if(pImpl->referenceCount==0) delete this;
|
||||
if(pImpl->type!=structure) {
|
||||
if(pImpl->referenceCount==0) {
|
||||
delete this;
|
||||
}
|
||||
return;
|
||||
}
|
||||
StructureConstPtr structure = static_cast<StructureConstPtr>(this);
|
||||
FieldConstPtrArray fields = structure->getFields();
|
||||
int numberFields = structure->getNumberFields();
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
fields[i]->decReferenceCount();
|
||||
}
|
||||
if(pImpl->referenceCount==0) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void Field:: dumpReferenceCount(StringBuilder buffer,int indentLevel) const {
|
||||
*buffer += getFieldName();
|
||||
char buf[40];
|
||||
sprintf(buf," referenceCount %d",getReferenceCount());
|
||||
*buffer += buf;
|
||||
if(pImpl->type!=structure) return;
|
||||
Convert *convert = getConvert();
|
||||
StructureConstPtr structure = static_cast<StructureConstPtr>(this);
|
||||
FieldConstPtrArray fields = structure->getFields();
|
||||
int numberFields = structure->getNumberFields();
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
convert->newLine(buffer,indentLevel+1);
|
||||
fields[i]->dumpReferenceCount(buffer,indentLevel +1);
|
||||
}
|
||||
}
|
||||
|
||||
void Field::toString(StringBuilder buffer,int indentLevel) const{
|
||||
*buffer += " ";
|
||||
@@ -217,7 +255,6 @@ void ScalarArray::toString(StringBuilder buffer,int indentLevel) const{
|
||||
StructureArray::StructureArray(String fieldName,StructureConstPtr structure)
|
||||
: Field(fieldName,structureArray),pstructure(structure)
|
||||
{
|
||||
pstructure->incReferenceCount();
|
||||
}
|
||||
|
||||
StructureArray::~StructureArray() {
|
||||
@@ -237,7 +274,7 @@ Structure::Structure (String fieldName,
|
||||
int numberFields, FieldConstPtrArray infields)
|
||||
: Field(fieldName,structure),
|
||||
numberFields(numberFields),
|
||||
fields(new FieldConstPtr[numberFields])
|
||||
fields(infields)
|
||||
{
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
fields[i] = infields[i];
|
||||
@@ -254,18 +291,14 @@ Structure::Structure (String fieldName,
|
||||
throw std::invalid_argument(message);
|
||||
}
|
||||
}
|
||||
// inc reference counter
|
||||
fields[i]->incReferenceCount();
|
||||
}
|
||||
this->incReferenceCount();
|
||||
}
|
||||
|
||||
Structure::~Structure() {
|
||||
if(debugLevel==highDebug)
|
||||
printf("~Structure %s\n",Field::getFieldName().c_str());
|
||||
for(int i=0; i<numberFields; i++) {
|
||||
FieldConstPtr pfield = fields[i];
|
||||
pfield->decReferenceCount();
|
||||
fields[i] = 0;
|
||||
}
|
||||
delete[] fields;
|
||||
}
|
||||
@@ -363,7 +396,7 @@ FieldCreate::FieldCreate()
|
||||
}
|
||||
|
||||
FieldCreate * getFieldCreate() {
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
|
||||
if(fieldCreate==0) fieldCreate = new FieldCreate();
|
||||
|
||||
@@ -13,36 +13,36 @@
|
||||
#include "convert.h"
|
||||
#include "factory.h"
|
||||
#include "lock.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("pvAuxInfo"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ PVAuxInfo::PVAuxInfo(PVField *pvField)
|
||||
: pImpl(new PVAuxInfoPvt(pvField))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
PVAuxInfo::~PVAuxInfo() {
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
map_iterator i = pImpl->theMap.begin();
|
||||
while(i!=pImpl->theMap.end()) {
|
||||
@@ -82,12 +82,6 @@ PVField * PVAuxInfo::getPVField() {
|
||||
return pImpl->pvField;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *PVAuxInfo::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pConstructDestructCallback;
|
||||
}
|
||||
|
||||
PVScalar * PVAuxInfo::createInfo(String key,ScalarType scalarType)
|
||||
{
|
||||
map_iterator i = pImpl->theMap.find(key);
|
||||
|
||||
@@ -122,6 +122,7 @@ PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
|
||||
PVScalar *PVDataCreate::createPVScalar(PVStructure *parent,
|
||||
String fieldName,PVScalar * scalarToClone)
|
||||
{
|
||||
scalarToClone->getField()->incReferenceCount();
|
||||
PVScalar *pvScalar = createPVScalar(parent,fieldName,
|
||||
scalarToClone->getScalar()->getScalarType());
|
||||
convert->copyScalar(scalarToClone, pvScalar);
|
||||
@@ -174,6 +175,7 @@ PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
|
||||
PVScalarArray *PVDataCreate::createPVScalarArray(PVStructure *parent,
|
||||
String fieldName,PVScalarArray * arrayToClone)
|
||||
{
|
||||
arrayToClone->getField()->incReferenceCount();
|
||||
PVScalarArray *pvArray = createPVScalarArray(parent,fieldName,
|
||||
arrayToClone->getScalarArray()->getElementType());
|
||||
convert->copyScalarArray(arrayToClone,0, pvArray,0,arrayToClone->getLength());
|
||||
@@ -199,7 +201,8 @@ PVStructureArray *PVDataCreate::createPVStructureArray(PVStructure *parent,
|
||||
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
|
||||
StructureConstPtr structure)
|
||||
{
|
||||
return new BasePVStructure(parent,structure);
|
||||
PVStructure *pvStructure = new BasePVStructure(parent,structure);
|
||||
return pvStructure;
|
||||
}
|
||||
|
||||
PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
|
||||
@@ -215,20 +218,23 @@ PVStructure *PVDataCreate::createPVStructure(PVStructure *parent,
|
||||
{
|
||||
FieldConstPtrArray fields = 0;
|
||||
int numberFields = 0;
|
||||
PVStructure *pvStructure = 0;;
|
||||
if(structToClone==0) {
|
||||
fields = new FieldConstPtr[0];
|
||||
StructureConstPtr structure = fieldCreate->createStructure(
|
||||
fieldName,numberFields,fields);
|
||||
pvStructure = new BasePVStructure(parent,structure);
|
||||
} else {
|
||||
fields = structToClone->getStructure()->getFields();
|
||||
numberFields = structToClone->getStructure()->getNumberFields();
|
||||
StructureConstPtr structure = structToClone->getStructure();
|
||||
structure->incReferenceCount();
|
||||
pvStructure = new BasePVStructure(parent,structure);
|
||||
convert->copyStructure(structToClone,pvStructure);
|
||||
}
|
||||
StructureConstPtr structure = fieldCreate->createStructure(fieldName,numberFields,fields);
|
||||
PVStructure *pvStructure = new BasePVStructure(parent,structure);
|
||||
if(structToClone!=0) convert->copyStructure(structToClone,pvStructure);
|
||||
return pvStructure;
|
||||
}
|
||||
|
||||
PVDataCreate * getPVDataCreate() {
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
|
||||
if(pvDataCreate==0){
|
||||
|
||||
@@ -10,12 +10,16 @@
|
||||
#include <lock.h>
|
||||
#include "pvIntrospect.h"
|
||||
#include "standardField.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
static StandardField* standardField = 0;
|
||||
|
||||
static String notImplemented("not implemented");
|
||||
static FieldCreate* fieldCreate = 0;
|
||||
static StandardField* standardField = 0;
|
||||
static String valueFieldName("value");
|
||||
|
||||
// following are preallocated structures
|
||||
@@ -33,6 +37,7 @@ static StructureConstPtr floatAlarmField = 0;
|
||||
static StructureConstPtr doubleAlarmField = 0;
|
||||
static StructureConstPtr enumeratedAlarmField = 0;
|
||||
|
||||
|
||||
static void createAlarm() {
|
||||
FieldConstPtrArray fields = new FieldConstPtr[2];
|
||||
fields[0] = fieldCreate->createScalar(String("severity"),pvInt);
|
||||
@@ -245,11 +250,11 @@ static StructureConstPtr createProperties(String fieldName,FieldConstPtr field,S
|
||||
FieldConstPtrArray fields = new FieldConstPtr[numFields];
|
||||
int next = 0;
|
||||
fields[next++] = field;
|
||||
if(gotAlarm) fields[next++] = alarmField;
|
||||
if(gotTimeStamp) fields[next++] = timeStampField;
|
||||
if(gotDisplay) fields[next++] = displayField;
|
||||
if(gotControl) fields[next++] = controlField;
|
||||
if(gotValueAlarm) fields[next++] = valueAlarm;
|
||||
if(gotAlarm) {fields[next++] = alarmField; alarmField->incReferenceCount();}
|
||||
if(gotTimeStamp) {fields[next++] = timeStampField; timeStampField->incReferenceCount();}
|
||||
if(gotDisplay) {fields[next++] = displayField; displayField->incReferenceCount();}
|
||||
if(gotControl) {fields[next++] = controlField; controlField->incReferenceCount();}
|
||||
if(gotValueAlarm) {fields[next++] = valueAlarm; valueAlarm->incReferenceCount();}
|
||||
return fieldCreate->createStructure(fieldName,numFields,fields);
|
||||
}
|
||||
|
||||
@@ -438,44 +443,74 @@ StructureConstPtr StandardField::enumeratedAlarm()
|
||||
void StandardField::init()
|
||||
{
|
||||
createAlarm();
|
||||
alarmField->incReferenceCount();
|
||||
createTimeStamp();
|
||||
timeStampField->incReferenceCount();
|
||||
createDisplay();
|
||||
displayField->incReferenceCount();
|
||||
createControl();
|
||||
controlField->incReferenceCount();
|
||||
createBooleanAlarm();
|
||||
booleanAlarmField->incReferenceCount();
|
||||
createByteAlarm();
|
||||
byteAlarmField->incReferenceCount();
|
||||
createShortAlarm();
|
||||
shortAlarmField->incReferenceCount();
|
||||
createIntAlarm();
|
||||
intAlarmField->incReferenceCount();
|
||||
createLongAlarm();
|
||||
longAlarmField->incReferenceCount();
|
||||
createFloatAlarm();
|
||||
floatAlarmField->incReferenceCount();
|
||||
createDoubleAlarm();
|
||||
doubleAlarmField->incReferenceCount();
|
||||
createEnumeratedAlarm();
|
||||
enumeratedAlarmField->incReferenceCount();
|
||||
}
|
||||
|
||||
|
||||
StandardField::StandardField(){init();}
|
||||
|
||||
StandardField::~StandardField(){}
|
||||
StandardField::~StandardField(){
|
||||
}
|
||||
|
||||
static void myDeleteStatic()
|
||||
{
|
||||
int count = alarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() alarmField reference count %d\n",count);
|
||||
alarmField->decReferenceCount();
|
||||
count = timeStampField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() timeStampField reference count %d\n",count);
|
||||
timeStampField->decReferenceCount();
|
||||
count = displayField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() displayField reference count %d\n",count);
|
||||
displayField->decReferenceCount();
|
||||
count = controlField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() controlField reference count %d\n",count);
|
||||
controlField->decReferenceCount();
|
||||
count = booleanAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() booleanAlarmField reference count %d\n",count);
|
||||
booleanAlarmField->decReferenceCount();
|
||||
count = byteAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() byteAlarmField reference count %d\n",count);
|
||||
byteAlarmField->decReferenceCount();
|
||||
count = shortAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() shortAlarmField reference count %d\n",count);
|
||||
shortAlarmField->decReferenceCount();
|
||||
count = intAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() intAlarmField reference count %d\n",count);
|
||||
intAlarmField->decReferenceCount();
|
||||
count = longAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() longAlarmField reference count %d\n",count);
|
||||
longAlarmField->decReferenceCount();
|
||||
count = floatAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() floatAlarmField reference count %d\n",count);
|
||||
floatAlarmField->decReferenceCount();
|
||||
count = doubleAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() doubleAlarmField reference count %d\n",count);
|
||||
doubleAlarmField->decReferenceCount();
|
||||
count = enumeratedAlarmField->getReferenceCount();
|
||||
if(count!=1) printf("~StandardField() enumeratedAlarmField reference count %d\n",count);
|
||||
enumeratedAlarmField->decReferenceCount();
|
||||
}
|
||||
|
||||
StandardField * getStandardField() {
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
|
||||
if(standardField==0) {
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
standardField = new StandardField();
|
||||
fieldCreate = getFieldCreate();
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"standardField",
|
||||
0,0,0,myDeleteStatic);
|
||||
}
|
||||
return standardField;
|
||||
}
|
||||
|
||||
@@ -12,13 +12,17 @@
|
||||
#include "convert.h"
|
||||
#include "standardField.h"
|
||||
#include "standardPVField.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
static StandardField *standardField = 0;
|
||||
|
||||
static String notImplemented("not implemented");
|
||||
static FieldCreate* fieldCreate = 0;
|
||||
static PVDataCreate* pvDataCreate = 0;
|
||||
static StandardField *standardField = 0;
|
||||
static StandardPVField *standardPVField = 0;
|
||||
|
||||
static void addExtendsStructureName(PVStructure *pvStructure,String properties)
|
||||
@@ -325,15 +329,22 @@ public:
|
||||
StandardPVFieldExt(): StandardPVField(){};
|
||||
};
|
||||
|
||||
StandardPVField * getStandardPVField() {
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
static void myDeleteStatic()
|
||||
{
|
||||
delete standardPVField;
|
||||
}
|
||||
|
||||
if(standardPVField==0) {
|
||||
StandardPVField * getStandardPVField() {
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
fieldCreate = getFieldCreate();
|
||||
pvDataCreate = getPVDataCreate();
|
||||
standardField = getStandardField();
|
||||
standardPVField = new StandardPVFieldExt();
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"standardPVField",
|
||||
0,0,0,myDeleteStatic);
|
||||
}
|
||||
return standardPVField;
|
||||
}
|
||||
|
||||
@@ -21,31 +21,29 @@ namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("status"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,19 +54,19 @@ class StatusImpl : public Status
|
||||
StatusImpl(StatusType type, String message) :
|
||||
m_type(type), m_message(message)
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
StatusImpl(StatusType type, String message, String stackDump) :
|
||||
m_type(type), m_message(message), m_stackDump(stackDump)
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
virtual ~StatusImpl() {
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
}
|
||||
|
||||
@@ -207,7 +205,7 @@ class StatusCreateImpl : public StatusCreate {
|
||||
static StatusCreate* statusCreate = 0;
|
||||
|
||||
StatusCreate* getStatusCreate() {
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
|
||||
if(statusCreate==0) statusCreate = new StatusCreateImpl();
|
||||
|
||||
+16
-16
@@ -8,38 +8,38 @@
|
||||
#include "stdio.h"
|
||||
#include "bitSet.h"
|
||||
#include "lock.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
|
||||
//static DebugLevel debugLevel = lowDebug;
|
||||
|
||||
|
||||
static Mutex globalMutex;
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("bitSet"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace epics { namespace pvData {
|
||||
initWords(BITS_PER_WORD);
|
||||
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ namespace epics { namespace pvData {
|
||||
initWords(nbits);
|
||||
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
BitSet::~BitSet() {
|
||||
delete[] words;
|
||||
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <stdexcept>
|
||||
#include <pvType.h>
|
||||
#include "factory.h"
|
||||
#include "showConstructDestruct.h"
|
||||
//#include "byteBuffer.h"
|
||||
//#include "serialize.h"
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
+13
-20
@@ -20,45 +20,44 @@
|
||||
#include "pvType.h"
|
||||
#include "lock.h"
|
||||
#include "event.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static Mutex globalMutex;
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static bool notInited = true;
|
||||
static String alreadyOn("already on list");
|
||||
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("event"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Event::~Event() {
|
||||
epicsEventDestroy(id);
|
||||
id = 0;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
}
|
||||
|
||||
@@ -67,16 +66,10 @@ Event::Event(bool full)
|
||||
: id(epicsEventCreate(full?epicsEventFull : epicsEventEmpty))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *Event::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pConstructDestructCallback;
|
||||
}
|
||||
|
||||
void Event::signal()
|
||||
{
|
||||
if(id==0) throw std::logic_error(String("event was deleted"));
|
||||
|
||||
@@ -8,11 +8,9 @@
|
||||
#define EVENT_H
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <epicsMutex.h>
|
||||
#include <epicsEvent.h>
|
||||
#include "noDefaultMethods.h"
|
||||
#include "pvType.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -20,7 +18,6 @@ class Event : private NoDefaultMethods {
|
||||
public:
|
||||
explicit Event(bool = false);
|
||||
~Event();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
void signal();
|
||||
bool wait (); /* blocks until full */
|
||||
bool wait ( double timeOut ); /* false if empty at time out */
|
||||
|
||||
+12
-19
@@ -17,35 +17,34 @@
|
||||
#include "thread.h"
|
||||
#include "event.h"
|
||||
#include "executor.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
|
||||
static void init() {
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("executor"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,12 +74,6 @@ ExecutorNode::~ExecutorNode()
|
||||
delete runNode;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *Executor::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pConstructDestructCallback;
|
||||
}
|
||||
|
||||
class ExecutorPvt : public Runnable{
|
||||
public:
|
||||
ExecutorPvt(String threadName,ThreadPriority priority);
|
||||
@@ -169,13 +162,13 @@ Executor::Executor(String threadName,ThreadPriority priority)
|
||||
: pImpl(new ExecutorPvt(threadName,priority))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalConstruct++;
|
||||
}
|
||||
|
||||
Executor::~Executor() {
|
||||
delete pImpl;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ class Executor : private NoDefaultMethods {
|
||||
public:
|
||||
Executor(String threadName,ThreadPriority priority);
|
||||
~Executor();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
ExecutorNode * createNode(Command *command);
|
||||
void execute(ExecutorNode *node);
|
||||
private:
|
||||
|
||||
@@ -14,56 +14,55 @@
|
||||
#include "lock.h"
|
||||
#include "pvType.h"
|
||||
#include "linkedListVoid.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
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 Mutex *globalMutex = 0;
|
||||
static String alreadyOnList("already on list");
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalNodeConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalNodeDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalListConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalListDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pCDCallbackLinkedListNode;
|
||||
static ConstructDestructCallback *pCDCallbackLinkedList;
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pCDCallbackLinkedListNode = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"linkedListNode",
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0);
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0,0);
|
||||
|
||||
pCDCallbackLinkedList = new ConstructDestructCallback(
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"linkedList",
|
||||
getTotalListConstruct,getTotalListDestruct,0);
|
||||
getTotalListConstruct,getTotalListDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +71,7 @@ LinkedListVoidNode::LinkedListVoidNode(void *object)
|
||||
: object(object),before(0),after(0),linkedListVoid(0)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
}
|
||||
|
||||
@@ -80,23 +79,17 @@ LinkedListVoidNode::LinkedListVoidNode(bool isHead)
|
||||
: object(this),before(this),after(this)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
}
|
||||
|
||||
|
||||
LinkedListVoidNode::~LinkedListVoidNode()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeDestruct++;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *LinkedListVoidNode::getConstructDestructCallback()
|
||||
{
|
||||
initPvt();
|
||||
return pCDCallbackLinkedListNode;
|
||||
}
|
||||
|
||||
void *LinkedListVoidNode::getObject() {
|
||||
return object;
|
||||
}
|
||||
@@ -111,23 +104,17 @@ LinkedListVoid::LinkedListVoid()
|
||||
: head(new LinkedListVoidNode(true)),length(0)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalListConstruct++;
|
||||
}
|
||||
|
||||
LinkedListVoid::~LinkedListVoid()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
delete head;
|
||||
totalListDestruct++;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *LinkedListVoid::getConstructDestructCallback()
|
||||
{
|
||||
initPvt();
|
||||
return pCDCallbackLinkedList;
|
||||
}
|
||||
|
||||
int LinkedListVoid::getLength()
|
||||
{
|
||||
return length;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "pvType.h"
|
||||
#include "showConstructDestruct.h"
|
||||
#ifndef LINKEDLISTVOID_H
|
||||
#define LINKEDLISTVOID_H
|
||||
namespace epics { namespace pvData {
|
||||
@@ -17,7 +16,6 @@ class LinkedListVoidNode;
|
||||
class LinkedListVoidNode {
|
||||
public:
|
||||
~LinkedListVoidNode();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
void *getObject();
|
||||
bool isOnList();
|
||||
protected:
|
||||
@@ -37,7 +35,6 @@ private:
|
||||
class LinkedListVoid {
|
||||
public:
|
||||
~LinkedListVoid();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
int getLength();
|
||||
void addTail(LinkedListVoidNode *listNode);
|
||||
void addHead(LinkedListVoidNode *listNode);
|
||||
|
||||
@@ -23,31 +23,29 @@ namespace epics { namespace pvData {
|
||||
|
||||
static volatile int64 totalQueueConstruct = 0;
|
||||
static volatile int64 totalQueueDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalQueueConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalQueueDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pCDCallbackQueue;
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pCDCallbackQueue = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"messageQueue",
|
||||
getTotalQueueConstruct,getTotalQueueDestruct,0);
|
||||
getTotalQueueConstruct,getTotalQueueDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +58,8 @@ typedef Queue<MessageNode> MessageNodeQueue;
|
||||
MessageNode::MessageNode()
|
||||
: message(String("")),messageType(infoMessage){}
|
||||
|
||||
MessageNode::~MessageNode() {}
|
||||
MessageNode::~MessageNode() {
|
||||
}
|
||||
|
||||
String MessageNode::getMessage() const { return message;};
|
||||
|
||||
@@ -81,7 +80,7 @@ MessageQueue::MessageQueue(int size)
|
||||
: pImpl(new MessageQueuePvt)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueConstruct++;
|
||||
pImpl->size = size;
|
||||
pImpl->overrun = 0;
|
||||
@@ -101,8 +100,7 @@ MessageQueue::~MessageQueue()
|
||||
delete pImpl->messageNodeArray[i];
|
||||
}
|
||||
delete[] pImpl->messageNodeArray;
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueDestruct++;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "pvType.h"
|
||||
#include "requester.h"
|
||||
#include "noDefaultMethods.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -29,7 +28,6 @@ class MessageQueue : private NoDefaultMethods {
|
||||
public:
|
||||
MessageQueue(int size);
|
||||
~MessageQueue();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
MessageNode *get();
|
||||
// must call release before next get
|
||||
void release();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "lock.h"
|
||||
#include "pvType.h"
|
||||
#include "queueVoid.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -21,48 +22,44 @@ static volatile int64 totalElementConstruct = 0;
|
||||
static volatile int64 totalElementDestruct = 0;
|
||||
static volatile int64 totalQueueConstruct = 0;
|
||||
static volatile int64 totalQueueDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalNodeConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalElementConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalNodeDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalElementDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalListDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalQueueDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pCDCallbackQueueNode;
|
||||
static ConstructDestructCallback *pCDCallbackQueue;
|
||||
|
||||
static void initPvt()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pCDCallbackQueueNode = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"queueElement",
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0);
|
||||
|
||||
pCDCallbackQueue = new ConstructDestructCallback(
|
||||
getTotalNodeConstruct,getTotalNodeDestruct,0,0);
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"queue",
|
||||
getTotalListConstruct,getTotalListDestruct,0);
|
||||
getTotalListConstruct,getTotalListDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,23 +68,17 @@ QueueElementVoid::QueueElementVoid(ObjectPtr object)
|
||||
: object(object)
|
||||
{
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalElementConstruct++;
|
||||
}
|
||||
|
||||
|
||||
QueueElementVoid::~QueueElementVoid()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalElementDestruct++;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *QueueElementVoid::getConstructDestructCallback()
|
||||
{
|
||||
initPvt();
|
||||
return pCDCallbackQueueNode;
|
||||
}
|
||||
|
||||
ObjectPtr QueueElementVoid::getObject() {
|
||||
return object;
|
||||
}
|
||||
@@ -104,7 +95,7 @@ QueueVoid::QueueVoid(ObjectPtr object[],int number)
|
||||
array[i] = new QueueElementVoid(object[i]);
|
||||
}
|
||||
initPvt();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueConstruct++;
|
||||
}
|
||||
|
||||
@@ -114,16 +105,10 @@ QueueVoid::~QueueVoid()
|
||||
delete array[i];
|
||||
}
|
||||
delete[]array;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalQueueDestruct++;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *QueueVoid::getConstructDestructCallback()
|
||||
{
|
||||
initPvt();
|
||||
return pCDCallbackQueue;
|
||||
}
|
||||
|
||||
void QueueVoid::clear()
|
||||
{
|
||||
numberFree = number;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* EPICS pvDataCPP is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
#include "showConstructDestruct.h"
|
||||
#ifndef QUEUEVOID_H
|
||||
#define QUEUEVOID_H
|
||||
namespace epics { namespace pvData {
|
||||
@@ -17,8 +16,6 @@ typedef QueueElementVoid * QueueElementVoidPtr;
|
||||
typedef QueueElementVoidPtr * QueueElementVoidPtrArray;
|
||||
|
||||
class QueueElementVoid {
|
||||
public:
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
protected:
|
||||
ObjectPtr getObject();
|
||||
QueueElementVoid(ObjectPtr object);
|
||||
@@ -29,8 +26,6 @@ protected:
|
||||
|
||||
|
||||
class QueueVoid {
|
||||
public:
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
protected:
|
||||
QueueVoid(ObjectPtr array[],int number);
|
||||
~QueueVoid();
|
||||
|
||||
@@ -20,20 +20,28 @@
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
static ShowConstructDestruct *pShowConstructDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
typedef LinkedListNode<ConstructDestructCallback> ListNode;
|
||||
typedef LinkedList<ConstructDestructCallback> List;
|
||||
static List *list;
|
||||
|
||||
/* list callbacks are special because showConstructDestruct creates a list
|
||||
Thus list can be null when list calls registerCallback
|
||||
The list callbacks are not put on the list but handled separately
|
||||
*/
|
||||
static ConstructDestructCallback *listCallback = 0;
|
||||
static ConstructDestructCallback *listNodeCallback = 0;
|
||||
|
||||
ConstructDestructCallback::ConstructDestructCallback(
|
||||
String name,
|
||||
getTotal construct,
|
||||
getTotal destruct,
|
||||
getTotal reference)
|
||||
: name(name), construct(construct), destruct(destruct) ,reference(reference)
|
||||
{
|
||||
getShowConstructDestruct()->registerCallback(this);
|
||||
}
|
||||
getTotalFunc construct,
|
||||
getTotalFunc destruct,
|
||||
getTotalFunc reference,
|
||||
deleteStaticFunc deleteFunc)
|
||||
: name(name), construct(construct), destruct(destruct) ,reference(reference),
|
||||
deleteFunc(deleteFunc)
|
||||
{ }
|
||||
|
||||
ConstructDestructCallback::~ConstructDestructCallback() {}
|
||||
|
||||
@@ -44,11 +52,13 @@ String ConstructDestructCallback::getConstructName()
|
||||
|
||||
int64 ConstructDestructCallback::getTotalConstruct()
|
||||
{
|
||||
if(construct==0) return 0;
|
||||
return construct();
|
||||
}
|
||||
|
||||
int64 ConstructDestructCallback:: getTotalDestruct()
|
||||
{
|
||||
if(destruct==0) return 0;
|
||||
return destruct();
|
||||
}
|
||||
|
||||
@@ -58,68 +68,142 @@ int64 ConstructDestructCallback::getTotalReferenceCount()
|
||||
return reference();
|
||||
}
|
||||
|
||||
void ConstructDestructCallback::deleteStatic()
|
||||
{
|
||||
if(deleteFunc==0) return;
|
||||
deleteFunc();
|
||||
}
|
||||
|
||||
ShowConstructDestruct::ShowConstructDestruct() {}
|
||||
|
||||
ShowConstructDestruct::~ShowConstructDestruct() {
|
||||
delete listCallback;
|
||||
delete listNodeCallback;
|
||||
listCallback = 0;
|
||||
listNodeCallback = 0;
|
||||
}
|
||||
|
||||
void ShowConstructDestruct::registerCallback(
|
||||
String name,
|
||||
getTotalFunc construct,
|
||||
getTotalFunc destruct,
|
||||
getTotalFunc reference,
|
||||
deleteStaticFunc deleteFunc)
|
||||
{
|
||||
getShowConstructDestruct(); // make it initialize
|
||||
Lock xx(&globalMutex);
|
||||
if(name.compare("linkedList")==0) {
|
||||
listCallback = new ConstructDestructCallback(
|
||||
name,construct,destruct,reference,deleteFunc);
|
||||
return;
|
||||
} else if(name.compare("linkedListNode")==0) {
|
||||
listNodeCallback = new ConstructDestructCallback(
|
||||
name,construct,destruct,reference,deleteFunc);
|
||||
return;
|
||||
}
|
||||
if(list==0) {
|
||||
throw std::logic_error(String(
|
||||
"ShowConstructDestruct::registerCallback"));
|
||||
}
|
||||
ConstructDestructCallback *callback = new ConstructDestructCallback(
|
||||
name,construct,destruct,reference,deleteFunc);
|
||||
ListNode *listNode = new ListNode(callback);
|
||||
list->addTail(listNode);
|
||||
}
|
||||
static void showOne(ConstructDestructCallback *callback,FILE *fd)
|
||||
{
|
||||
String name = callback->getConstructName();
|
||||
int64 reference = callback->getTotalReferenceCount();
|
||||
int64 construct = callback->getTotalConstruct();
|
||||
int64 destruct = callback->getTotalDestruct();
|
||||
if(reference==0&&construct==0&&destruct==0) return;
|
||||
fprintf(fd,"%s: ", name.c_str());
|
||||
if(construct>0 || destruct>0) {
|
||||
fprintf(fd," totalConstruct %lli totalDestruct %lli",
|
||||
construct,destruct);
|
||||
}
|
||||
if(reference>0) fprintf(fd," totalReference %lli",reference);
|
||||
int64 diff = construct - destruct;
|
||||
if(diff!=0) fprintf(fd," ACTIVE %lli",diff);
|
||||
fprintf(fd,"\n");
|
||||
}
|
||||
|
||||
ConstructDestructCallback* ShowConstructDestruct::getConstructDestructCallback(
|
||||
String name)
|
||||
{
|
||||
if(name.compare(listNodeCallback->getConstructName())==0) {
|
||||
return listNodeCallback;
|
||||
}
|
||||
if(name.compare(listCallback->getConstructName())==0) {
|
||||
return listCallback;
|
||||
}
|
||||
Lock xx(&globalMutex);
|
||||
ListNode *node = list->getHead();
|
||||
while(node!=0) {
|
||||
ConstructDestructCallback *callback = node->getObject();
|
||||
if(name.compare(callback->getConstructName())==0) {
|
||||
return callback;
|
||||
}
|
||||
node = list->getNext(node);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ShowConstructDestruct::constuctDestructTotals(FILE *fd)
|
||||
{
|
||||
getShowConstructDestruct(); // make it initialize
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
ListNode *node = list->getHead();
|
||||
while(node!=0) {
|
||||
ConstructDestructCallback *callback = node->getObject();
|
||||
String name = callback->getConstructName();
|
||||
int64 reference = callback->getTotalReferenceCount();
|
||||
int64 construct = callback->getTotalConstruct();
|
||||
int64 destruct = callback->getTotalDestruct();
|
||||
fprintf(fd,"%s: totalConstruct %lli totalDestruct %lli",
|
||||
name.c_str(),construct,destruct);
|
||||
if(reference>0) fprintf(fd," totalReference %lli",reference);
|
||||
fprintf(fd,"\n");
|
||||
showOne(callback,fd);
|
||||
node = list->getNext(node);
|
||||
}
|
||||
showOne(listNodeCallback,fd);
|
||||
showOne(listCallback,fd);
|
||||
}
|
||||
|
||||
void ShowConstructDestruct::registerCallback(ConstructDestructCallback *callback)
|
||||
void ShowConstructDestruct::showDeleteStaticExit(FILE *fd)
|
||||
{
|
||||
static ConstructDestructCallback *listCallback = 0;
|
||||
static ConstructDestructCallback *listNodeCallback = 0;
|
||||
Lock xx(globalMutex);
|
||||
ListNode *listNode = 0;
|
||||
if(list==0) {
|
||||
if(callback->getConstructName().compare("linkedListNode")==0) {
|
||||
listNodeCallback = callback;
|
||||
} else if(callback->getConstructName().compare("linkedList")==0) {
|
||||
listCallback = callback;
|
||||
} else {
|
||||
throw std::logic_error(String("ShowConstructDestruct::registerCallback"));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(listCallback!=0) {
|
||||
if(listNodeCallback==0) {
|
||||
throw std::logic_error(String(
|
||||
"ShowConstructDestruct::registerCallback expected listNodeCallback!=0"));
|
||||
}
|
||||
listNode = new ListNode(listNodeCallback);
|
||||
list->addTail(listNode);
|
||||
listNode = new ListNode(listCallback);
|
||||
list->addTail(listNode);
|
||||
listCallback = 0;
|
||||
listNodeCallback = 0;
|
||||
}
|
||||
listNode = new ListNode(callback);
|
||||
list->addTail(listNode);
|
||||
getShowConstructDestruct(); // make it initialize
|
||||
{
|
||||
Lock xx(&globalMutex);
|
||||
ListNode *node = list->getHead();
|
||||
while(node!=0) {
|
||||
ConstructDestructCallback *callback = node->getObject();
|
||||
if(callback->deleteFunc!=0) callback->deleteFunc();
|
||||
node = list->getNext(node);
|
||||
}
|
||||
node = list->getHead();
|
||||
while(node!=0) {
|
||||
ConstructDestructCallback *callback = node->getObject();
|
||||
showOne(callback,fd);
|
||||
list->removeHead();
|
||||
delete callback;
|
||||
delete node;
|
||||
node = list->getHead();
|
||||
}
|
||||
delete list;
|
||||
if(listNodeCallback->deleteFunc!=0) listNodeCallback->deleteFunc();
|
||||
if(listCallback->deleteFunc!=0) listCallback->deleteFunc();
|
||||
showOne(listNodeCallback,fd);
|
||||
showOne(listCallback,fd);
|
||||
delete pShowConstructDestruct;
|
||||
pShowConstructDestruct = 0;
|
||||
}
|
||||
exit( 0);
|
||||
}
|
||||
|
||||
ShowConstructDestruct * getShowConstructDestruct()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
static Mutex mutex;
|
||||
Lock xx(&mutex);
|
||||
if(pShowConstructDestruct==0) {
|
||||
globalMutex = new Mutex();
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
pShowConstructDestruct = new ShowConstructDestruct();
|
||||
list = new List();
|
||||
List *listTemp;
|
||||
listTemp = new List();
|
||||
list = listTemp;
|
||||
}
|
||||
return pShowConstructDestruct;
|
||||
}
|
||||
|
||||
@@ -17,33 +17,46 @@
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
typedef int64 (*getTotal)();
|
||||
typedef int64 (*getTotalFunc)();
|
||||
typedef void (*deleteStaticFunc)();
|
||||
|
||||
class ConstructDestructCallback : private NoDefaultMethods {
|
||||
public:
|
||||
ConstructDestructCallback(
|
||||
String name,
|
||||
getTotal construct,
|
||||
getTotal destruct,
|
||||
getTotal reference);
|
||||
String getConstructName();
|
||||
int64 getTotalConstruct();
|
||||
int64 getTotalDestruct();
|
||||
int64 getTotalReferenceCount();
|
||||
private:
|
||||
ConstructDestructCallback(
|
||||
String name,
|
||||
getTotalFunc construct,
|
||||
getTotalFunc destruct,
|
||||
getTotalFunc reference,
|
||||
deleteStaticFunc deleteFunc);
|
||||
~ConstructDestructCallback();
|
||||
void deleteStatic();
|
||||
String name;
|
||||
getTotal construct;
|
||||
getTotal destruct;
|
||||
getTotal reference;
|
||||
getTotalFunc construct;
|
||||
getTotalFunc destruct;
|
||||
getTotalFunc reference;
|
||||
deleteStaticFunc deleteFunc;
|
||||
friend class ShowConstructDestruct;
|
||||
};
|
||||
|
||||
class ShowConstructDestruct : private NoDefaultMethods {
|
||||
public:
|
||||
static void registerCallback(
|
||||
String name,
|
||||
getTotalFunc construct,
|
||||
getTotalFunc destruct,
|
||||
getTotalFunc reference,
|
||||
deleteStaticFunc deleteFunc);
|
||||
ConstructDestructCallback* getConstructDestructCallback(String name);
|
||||
void constuctDestructTotals(FILE *fd);
|
||||
void registerCallback(ConstructDestructCallback *callback);
|
||||
static void showDeleteStaticExit(FILE *fd);
|
||||
private:
|
||||
ShowConstructDestruct();
|
||||
~ShowConstructDestruct();
|
||||
friend ShowConstructDestruct* getShowConstructDestruct();
|
||||
};
|
||||
|
||||
@@ -56,41 +69,39 @@ extern ShowConstructDestruct* getShowConstructDestruct();
|
||||
#define PVDATA_REFCOUNT_MONITOR_DEFINE(NAME) \
|
||||
static volatile int64 NAME ## _totalConstruct = 0; \
|
||||
static volatile int64 NAME ## _totalDestruct = 0; \
|
||||
static Mutex * NAME ## _globalMutex = 0; \
|
||||
static Mutex globalMutex; \
|
||||
\
|
||||
static bool notInited = true; \
|
||||
static int64 NAME ## _processTotalConstruct() \
|
||||
{ \
|
||||
Lock xx(NAME ## _globalMutex); \
|
||||
Lock xx(&globalMutex); \
|
||||
return NAME ## _totalConstruct; \
|
||||
} \
|
||||
\
|
||||
static int64 NAME ## _processTotalDestruct() \
|
||||
{ \
|
||||
Lock xx(NAME ## _globalMutex); \
|
||||
Lock xx(&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), \
|
||||
Lock xx(&globalMutex); \
|
||||
if(notInited) { \
|
||||
notInited = false; \
|
||||
ShowConstructDestruct::registerCallback( \
|
||||
String("#NAME"), \
|
||||
NAME ## _processTotalConstruct,NAME ## _processTotalDestruct,0); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PVDATA_REFCOUNT_MONITOR_DESTRUCT(NAME) \
|
||||
Lock xx(NAME ## _globalMutex); \
|
||||
Lock xx(&globalMutex); \
|
||||
NAME ## _totalDestruct++;
|
||||
|
||||
#define PVDATA_REFCOUNT_MONITOR_CONSTRUCT(NAME) \
|
||||
NAME ## _init(); \
|
||||
Lock xx(NAME ## _globalMutex); \
|
||||
Lock xx(&globalMutex); \
|
||||
NAME ## _totalConstruct++;
|
||||
|
||||
|
||||
|
||||
+17
-19
@@ -17,6 +17,7 @@
|
||||
#include "event.h"
|
||||
#include "thread.h"
|
||||
#include "linkedList.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -48,33 +49,36 @@ typedef LinkedList<ThreadListElement> ThreadList;
|
||||
|
||||
static volatile int64 totalConstruct = 0;
|
||||
static volatile int64 totalDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
static ThreadList *threadList;
|
||||
|
||||
static int64 getTotalConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pConstructDestructCallback;
|
||||
static void deleteStatic()
|
||||
{
|
||||
delete threadList;
|
||||
}
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
threadList = new ThreadList();
|
||||
pConstructDestructCallback = new ConstructDestructCallback(
|
||||
ShowConstructDestruct::registerCallback(
|
||||
String("thread"),
|
||||
getTotalConstruct,getTotalDestruct,0);
|
||||
getTotalConstruct,getTotalDestruct,0,deleteStatic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +137,7 @@ ThreadPvt::ThreadPvt(Thread *thread,String name,
|
||||
myFunc,this))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
threadList->addTail(threadListElement->node);
|
||||
totalConstruct++;
|
||||
}
|
||||
@@ -157,7 +161,7 @@ ThreadPvt::~ThreadPvt()
|
||||
threadList->remove(threadListElement->node);
|
||||
delete waitDone;
|
||||
delete threadListElement;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalDestruct++;
|
||||
}
|
||||
|
||||
@@ -171,12 +175,6 @@ Thread::~Thread()
|
||||
delete pImpl;
|
||||
}
|
||||
|
||||
ConstructDestructCallback *Thread::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pConstructDestructCallback;
|
||||
}
|
||||
|
||||
void Thread::sleep(double seconds)
|
||||
{
|
||||
epicsThreadSleep(seconds);;
|
||||
@@ -195,7 +193,7 @@ ThreadPriority Thread::getPriority()
|
||||
void Thread::showThreads(StringBuilder buf)
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
ThreadListNode *node = threadList->getHead();
|
||||
while(node!=0) {
|
||||
Thread *thread = node->getObject()->thread;
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define THREAD_H
|
||||
#include "noDefaultMethods.h"
|
||||
#include "pvType.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -39,7 +38,6 @@ class Thread : private NoDefaultMethods {
|
||||
public:
|
||||
Thread(String name,ThreadPriority priority,Runnable *runnable);
|
||||
~Thread();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
String getName();
|
||||
ThreadPriority getPriority();
|
||||
static void showThreads(StringBuilder buf);
|
||||
|
||||
+17
-33
@@ -28,63 +28,47 @@ static volatile int64 totalNodeConstruct = 0;
|
||||
static volatile int64 totalNodeDestruct = 0;
|
||||
static volatile int64 totalTimerConstruct = 0;
|
||||
static volatile int64 totalTimerDestruct = 0;
|
||||
static Mutex *globalMutex = 0;
|
||||
static Mutex globalMutex;
|
||||
static bool notInited = true;
|
||||
|
||||
static int64 getTotalTimerNodeConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerNodeDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalNodeDestruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerConstruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalTimerConstruct;
|
||||
}
|
||||
|
||||
static int64 getTotalTimerDestruct()
|
||||
{
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
return totalTimerDestruct;
|
||||
}
|
||||
|
||||
static ConstructDestructCallback *pCDCallbackTimerNode;
|
||||
static ConstructDestructCallback *pCDCallbackTimer;
|
||||
|
||||
static void init()
|
||||
{
|
||||
static Mutex mutex = Mutex();
|
||||
Lock xx(&mutex);
|
||||
if(globalMutex==0) {
|
||||
globalMutex = new Mutex();
|
||||
pCDCallbackTimerNode = new ConstructDestructCallback(
|
||||
Lock xx(&globalMutex);
|
||||
if(notInited) {
|
||||
notInited = false;
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"timerNode",
|
||||
getTotalTimerNodeConstruct,getTotalTimerNodeDestruct,0);
|
||||
|
||||
pCDCallbackTimer = new ConstructDestructCallback(
|
||||
getTotalTimerNodeConstruct,getTotalTimerNodeDestruct,0,0);
|
||||
ShowConstructDestruct::registerCallback(
|
||||
"timer",
|
||||
getTotalTimerConstruct,getTotalTimerDestruct,0);
|
||||
getTotalTimerConstruct,getTotalTimerDestruct,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
ConstructDestructCallback * TimerNode::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pCDCallbackTimerNode;
|
||||
}
|
||||
|
||||
ConstructDestructCallback * Timer::getConstructDestructCallback()
|
||||
{
|
||||
init();
|
||||
return pCDCallbackTimer;
|
||||
}
|
||||
|
||||
class TimerNodePvt;
|
||||
|
||||
typedef LinkedListNode<TimerNodePvt> TimerListNode;
|
||||
@@ -171,7 +155,7 @@ TimerNode::TimerNode(TimerCallback *callback)
|
||||
: pImpl(new TimerNodePvt(this,callback))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeConstruct++;
|
||||
}
|
||||
|
||||
@@ -180,7 +164,7 @@ TimerNode::~TimerNode()
|
||||
{
|
||||
cancel();
|
||||
delete pImpl;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalNodeDestruct++;
|
||||
}
|
||||
|
||||
@@ -257,7 +241,7 @@ Timer::Timer(String threadName, ThreadPriority priority)
|
||||
: pImpl(new TimerPvt(threadName,priority))
|
||||
{
|
||||
init();
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalTimerConstruct++;
|
||||
}
|
||||
|
||||
@@ -274,7 +258,7 @@ Timer::~Timer() {
|
||||
node->getObject()->callback->timerStopped();
|
||||
}
|
||||
delete pImpl;
|
||||
Lock xx(globalMutex);
|
||||
Lock xx(&globalMutex);
|
||||
totalTimerDestruct++;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "pvType.h"
|
||||
#include "thread.h"
|
||||
#include "noDefaultMethods.h"
|
||||
#include "showConstructDestruct.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -29,7 +28,6 @@ class TimerNode : private NoDefaultMethods {
|
||||
public:
|
||||
TimerNode(TimerCallback *timerCallback);
|
||||
~TimerNode();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
void cancel();
|
||||
bool isScheduled();
|
||||
private:
|
||||
@@ -41,7 +39,6 @@ class Timer : private NoDefaultMethods {
|
||||
public:
|
||||
Timer(String threadName, ThreadPriority priority);
|
||||
~Timer();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
void scheduleAfterDelay(TimerNode *timerNode,double delay);
|
||||
void schedulePeriodic(TimerNode *timerNode,double delay,double period);
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include "requester.h"
|
||||
#include "byteBuffer.h"
|
||||
#include "serialize.h"
|
||||
#include "showConstructDestruct.h"
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
class PVAuxInfo;
|
||||
@@ -63,7 +62,6 @@ class PVAuxInfo : private NoDefaultMethods {
|
||||
public:
|
||||
PVAuxInfo(PVField *pvField);
|
||||
~PVAuxInfo();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
PVField * getPVField();
|
||||
PVScalar * createInfo(String key,ScalarType scalarType);
|
||||
PVScalarMap getInfos();
|
||||
@@ -87,7 +85,6 @@ class PVField
|
||||
{
|
||||
public:
|
||||
virtual ~PVField();
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
String getRequesterName() ;
|
||||
virtual void message(String message,MessageType messageType) ;
|
||||
virtual void setRequester(Requester *prequester);
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#define PVINTROSPECT_H
|
||||
#include "noDefaultMethods.h"
|
||||
#include "pvType.h"
|
||||
#include "showConstructDestruct.h"
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
class Field;
|
||||
@@ -60,7 +59,6 @@ public:
|
||||
|
||||
class Field : private NoDefaultMethods {
|
||||
public:
|
||||
static ConstructDestructCallback *getConstructDestructCallback();
|
||||
int getReferenceCount() const;
|
||||
String getFieldName() const;
|
||||
Type getType() const;
|
||||
@@ -68,6 +66,7 @@ public:
|
||||
virtual void toString(StringBuilder buf,int indentLevel) const;
|
||||
void incReferenceCount() const;
|
||||
void decReferenceCount() const;
|
||||
void dumpReferenceCount(StringBuilder buf,int indentLevel) const;
|
||||
virtual bool operator==(const Field& field) const;
|
||||
virtual bool operator!=(const Field& field) const;
|
||||
protected:
|
||||
|
||||
+4
-4
@@ -77,7 +77,7 @@ structure value
|
||||
structure timeStamp
|
||||
long secondsPastEpoch
|
||||
int nanoSeconds
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 156 totalDestruct 43 totalReference 169
|
||||
pvField: totalConstruct 55 totalDestruct 55
|
||||
field: totalConstruct 120 totalDestruct 120
|
||||
pvField: totalConstruct 47 totalDestruct 47
|
||||
linkedListNode: totalConstruct 4 totalDestruct 4
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
82c82
|
||||
< field: totalConstruct 156 totalDestruct 43 totalReference 169
|
||||
---
|
||||
> field: totalConstruct 156 totalDestruct 63 totalReference 93
|
||||
|
||||
@@ -77,7 +77,7 @@ structure value
|
||||
structure timeStamp
|
||||
long secondsPastEpoch
|
||||
int nanoSeconds
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 156 totalDestruct 63 totalReference 93
|
||||
pvField: totalConstruct 55 totalDestruct 55
|
||||
field: totalConstruct 120 totalDestruct 120
|
||||
pvField: totalConstruct 47 totalDestruct 47
|
||||
linkedListNode: totalConstruct 4 totalDestruct 4
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
+2
-2
@@ -17,5 +17,5 @@ stack 4 3 2 1 0
|
||||
|
||||
Ordered Queue test
|
||||
list 0 1 2 3 4
|
||||
linkedListNode: totalConstruct 4041 totalDestruct 4038
|
||||
linkedList: totalConstruct 9 totalDestruct 8
|
||||
linkedListNode: totalConstruct 4039 totalDestruct 4039
|
||||
linkedList: totalConstruct 9 totalDestruct 9
|
||||
|
||||
+12
-12
@@ -1,20 +1,20 @@
|
||||
|
||||
Time test
|
||||
diff 27.074538 milliSeconds
|
||||
time per iteration 27.074538 microseconds
|
||||
time per addTail/removeHead 0.013537 microseconds
|
||||
diff 23.623024 milliSeconds
|
||||
time per iteration 23.623024 microseconds
|
||||
time per addTail/removeHead 0.011812 microseconds
|
||||
|
||||
Time test locked
|
||||
diff 173.292669 milliSeconds
|
||||
time per iteration 173.292669 microseconds
|
||||
time per addTail/removeHead 0.086646 microseconds
|
||||
diff 178.929120 milliSeconds
|
||||
time per iteration 178.929120 microseconds
|
||||
time per addTail/removeHead 0.089465 microseconds
|
||||
|
||||
Time std::list test
|
||||
diff 649.310063 milliSeconds
|
||||
time per iteration 649.310063 microseconds
|
||||
time per addTail/removeHead 0.324655 microseconds
|
||||
diff 632.698846 milliSeconds
|
||||
time per iteration 632.698846 microseconds
|
||||
time per addTail/removeHead 0.316349 microseconds
|
||||
|
||||
Time std::list test locked
|
||||
diff 799.799680 milliSeconds
|
||||
time per iteration 799.799680 microseconds
|
||||
time per addTail/removeHead 0.399900 microseconds
|
||||
diff 788.837800 milliSeconds
|
||||
time per iteration 788.837800 microseconds
|
||||
time per addTail/removeHead 0.394419 microseconds
|
||||
|
||||
@@ -17,5 +17,5 @@ stack 4 3 2 1 0
|
||||
|
||||
Ordered Queue test
|
||||
list 0 1 2 3 4
|
||||
linkedListNode: totalConstruct 4041 totalDestruct 4038
|
||||
linkedList: totalConstruct 9 totalDestruct 8
|
||||
linkedListNode: totalConstruct 4039 totalDestruct 4039
|
||||
linkedList: totalConstruct 9 totalDestruct 9
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
linkedListNode: totalConstruct 6 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
messageQueue: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 3 totalDestruct 3
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
message 1 messageType info
|
||||
message 4 messageType info
|
||||
messageQueue: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 3 totalDestruct 3
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 4 totalDestruct 4
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
message 1 messageType info
|
||||
message 4 messageType info
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
linkedListNode: totalConstruct 6 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
messageQueue: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 3 totalDestruct 3
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
message 1 messageType info
|
||||
message 4 messageType info
|
||||
messageQueue: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 3 totalDestruct 3
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 4 totalDestruct 4
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
+5
-5
@@ -33,8 +33,8 @@ units offset 11 next 12 number 1
|
||||
limit offset 12 next 15 number 3
|
||||
low offset 13 next 14 number 1
|
||||
high offset 14 next 15 number 1
|
||||
linkedListNode: totalConstruct 6 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 111 totalDestruct 12 totalReference 126
|
||||
pvField: totalConstruct 17 totalDestruct 17
|
||||
pvAuxInfo: totalConstruct 1 totalDestruct 1
|
||||
field: totalConstruct 97 totalDestruct 97
|
||||
pvField: totalConstruct 17 totalDestruct 17
|
||||
pvAuxInfo: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 6 totalDestruct 6
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
38c38
|
||||
< field: totalConstruct 111 totalDestruct 12 totalReference 126
|
||||
---
|
||||
> field: totalConstruct 111 totalDestruct 18 totalReference 93
|
||||
|
||||
@@ -33,8 +33,8 @@ units offset 11 next 12 number 1
|
||||
limit offset 12 next 15 number 3
|
||||
low offset 13 next 14 number 1
|
||||
high offset 14 next 15 number 1
|
||||
linkedListNode: totalConstruct 6 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 111 totalDestruct 18 totalReference 93
|
||||
pvField: totalConstruct 17 totalDestruct 17
|
||||
pvAuxInfo: totalConstruct 1 totalDestruct 1
|
||||
field: totalConstruct 97 totalDestruct 97
|
||||
pvField: totalConstruct 17 totalDestruct 17
|
||||
pvAuxInfo: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 6 totalDestruct 6
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
+4
-4
@@ -283,7 +283,7 @@ structure string
|
||||
timeStamp timeStamp
|
||||
long secondsPastEpoch 0
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 391 totalDestruct 202 totalReference 443
|
||||
pvField: totalConstruct 281 totalDestruct 281
|
||||
field: totalConstruct 136 totalDestruct 136
|
||||
pvField: totalConstruct 281 totalDestruct 281
|
||||
linkedListNode: totalConstruct 5 totalDestruct 5
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
1,2d0
|
||||
< structure request
|
||||
< string fieldList value,timeStamp
|
||||
288,289c286,287
|
||||
< field: totalConstruct 391 totalDestruct 202 totalReference 443
|
||||
< pvField: totalConstruct 281 totalDestruct 281
|
||||
---
|
||||
> field: totalConstruct 388 totalDestruct 295 totalReference 93
|
||||
> pvField: totalConstruct 279 totalDestruct 279
|
||||
|
||||
+6
-4
@@ -1,3 +1,5 @@
|
||||
structure request
|
||||
string fieldList value,timeStamp
|
||||
|
||||
testScalar
|
||||
boolean boolean true
|
||||
@@ -281,7 +283,7 @@ structure string
|
||||
timeStamp timeStamp
|
||||
long secondsPastEpoch 0
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 388 totalDestruct 295 totalReference 93
|
||||
pvField: totalConstruct 279 totalDestruct 279
|
||||
field: totalConstruct 136 totalDestruct 136
|
||||
pvField: totalConstruct 281 totalDestruct 281
|
||||
linkedListNode: totalConstruct 5 totalDestruct 5
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -54,7 +54,15 @@ structure powerSupply
|
||||
timeStamp timeStamp
|
||||
long secondsPastEpoch 0
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 153 totalDestruct 31 totalReference 185
|
||||
pvField: totalConstruct 56 totalDestruct 56
|
||||
reference counts powerSupply referenceCount 1
|
||||
value referenceCount 1
|
||||
alarm referenceCount 14
|
||||
severity referenceCount 14
|
||||
message referenceCount 14
|
||||
timeStamp referenceCount 2
|
||||
secondsPastEpoch referenceCount 2
|
||||
nanoSeconds referenceCount 2
|
||||
field: totalConstruct 102 totalDestruct 102
|
||||
pvField: totalConstruct 56 totalDestruct 56
|
||||
linkedListNode: totalConstruct 5 totalDestruct 5
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
59c59
|
||||
< field: totalConstruct 153 totalDestruct 31 totalReference 185
|
||||
---
|
||||
> field: totalConstruct 153 totalDestruct 60 totalReference 93
|
||||
|
||||
@@ -54,7 +54,15 @@ structure powerSupply
|
||||
timeStamp timeStamp
|
||||
long secondsPastEpoch 0
|
||||
int nanoSeconds 0
|
||||
linkedListNode: totalConstruct 5 totalDestruct 0
|
||||
linkedList: totalConstruct 1 totalDestruct 0
|
||||
field: totalConstruct 153 totalDestruct 60 totalReference 93
|
||||
pvField: totalConstruct 56 totalDestruct 56
|
||||
reference counts powerSupply referenceCount 1
|
||||
value referenceCount 1
|
||||
alarm referenceCount 14
|
||||
severity referenceCount 14
|
||||
message referenceCount 14
|
||||
timeStamp referenceCount 2
|
||||
secondsPastEpoch referenceCount 2
|
||||
nanoSeconds referenceCount 2
|
||||
field: totalConstruct 102 totalDestruct 102
|
||||
pvField: totalConstruct 56 totalDestruct 56
|
||||
linkedListNode: totalConstruct 5 totalDestruct 5
|
||||
linkedList: totalConstruct 1 totalDestruct 1
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
linkedListNode: totalConstruct 9 totalDestruct 1
|
||||
linkedList: totalConstruct 2 totalDestruct 0
|
||||
queueElement: totalConstruct 5 totalDestruct 5
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
event: totalConstruct 5 totalDestruct 5
|
||||
thread: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 5 totalDestruct 5
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
event: totalConstruct 5 totalDestruct 5
|
||||
thread: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 7 totalDestruct 7
|
||||
linkedList: totalConstruct 2 totalDestruct 2
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
linkedListNode: totalConstruct 9 totalDestruct 1
|
||||
linkedList: totalConstruct 2 totalDestruct 0
|
||||
queueElement: totalConstruct 5 totalDestruct 5
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
event: totalConstruct 5 totalDestruct 5
|
||||
thread: totalConstruct 1 totalDestruct 1
|
||||
queueElement: totalConstruct 5 totalDestruct 5
|
||||
queue: totalConstruct 1 totalDestruct 1
|
||||
event: totalConstruct 5 totalDestruct 5
|
||||
thread: totalConstruct 1 totalDestruct 1
|
||||
linkedListNode: totalConstruct 7 totalDestruct 7
|
||||
linkedList: totalConstruct 2 totalDestruct 2
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
threads
|
||||
basic middle
|
||||
|
||||
linkedListNode: totalConstruct 17 totalDestruct 10
|
||||
linkedList: totalConstruct 6 totalDestruct 4
|
||||
event: totalConstruct 8 totalDestruct 8
|
||||
thread: totalConstruct 2 totalDestruct 2
|
||||
executor: totalConstruct 2 totalDestruct 2
|
||||
event: totalConstruct 8 totalDestruct 8
|
||||
thread: totalConstruct 2 totalDestruct 2
|
||||
executor: totalConstruct 2 totalDestruct 2
|
||||
linkedListNode: totalConstruct 15 totalDestruct 15
|
||||
linkedList: totalConstruct 6 totalDestruct 6
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
time per call 41.194820 microseconds
|
||||
time per call 37.293004 microseconds
|
||||
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
threads
|
||||
basic middle
|
||||
|
||||
linkedListNode: totalConstruct 17 totalDestruct 10
|
||||
linkedList: totalConstruct 6 totalDestruct 4
|
||||
event: totalConstruct 8 totalDestruct 8
|
||||
thread: totalConstruct 2 totalDestruct 2
|
||||
executor: totalConstruct 2 totalDestruct 2
|
||||
event: totalConstruct 8 totalDestruct 8
|
||||
thread: totalConstruct 2 totalDestruct 2
|
||||
executor: totalConstruct 2 totalDestruct 2
|
||||
linkedListNode: totalConstruct 15 totalDestruct 15
|
||||
linkedList: totalConstruct 6 totalDestruct 6
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
current 1293395469 853440425 milliSec 1293395469853
|
||||
2010.12.26 15:31:09 853440425 nanoSeconds isDst false
|
||||
current 1294842528 236065826 milliSec 1294842528236
|
||||
2011.01.12 09:28:48 236065826 nanoSeconds isDst false
|
||||
fromTime_t
|
||||
current 1293395469 0 milliSec 1293395469000
|
||||
2010.12.26 15:31:09 0 nanoSeconds isDst false
|
||||
current 1294842528 0 milliSec 1294842528000
|
||||
2011.01.12 09:28:48 0 nanoSeconds isDst false
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
linkedListNode: totalConstruct 20 totalDestruct 12
|
||||
linkedList: totalConstruct 5 totalDestruct 3
|
||||
event: totalConstruct 15 totalDestruct 15
|
||||
thread: totalConstruct 3 totalDestruct 3
|
||||
timerNode: totalConstruct 6 totalDestruct 6
|
||||
timer: totalConstruct 3 totalDestruct 3
|
||||
event: totalConstruct 15 totalDestruct 15
|
||||
thread: totalConstruct 3 totalDestruct 3
|
||||
timerNode: totalConstruct 6 totalDestruct 6
|
||||
timer: totalConstruct 3 totalDestruct 3
|
||||
linkedListNode: totalConstruct 18 totalDestruct 18
|
||||
linkedList: totalConstruct 5 totalDestruct 5
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
one requested 0.400000 diff 0.400393 seconds
|
||||
two requested 0.200000 diff 0.200411 seconds
|
||||
one requested 0.200000 diff 0.200244 seconds
|
||||
two requested 0.400000 diff 0.400291 seconds
|
||||
one requested 0.000000 diff 0.000131 seconds
|
||||
two requested 0.000000 diff 0.000155 seconds
|
||||
one requested 0.400000 diff 0.400196 seconds
|
||||
two requested 0.200000 diff 0.200182 seconds
|
||||
one requested 0.200000 diff 0.200248 seconds
|
||||
two requested 0.400000 diff 0.400307 seconds
|
||||
one requested 0.000000 diff 0.000033 seconds
|
||||
two requested 0.000000 diff 0.000049 seconds
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
linkedListNode: totalConstruct 20 totalDestruct 12
|
||||
linkedList: totalConstruct 5 totalDestruct 3
|
||||
event: totalConstruct 15 totalDestruct 15
|
||||
thread: totalConstruct 3 totalDestruct 3
|
||||
timerNode: totalConstruct 6 totalDestruct 6
|
||||
timer: totalConstruct 3 totalDestruct 3
|
||||
event: totalConstruct 15 totalDestruct 15
|
||||
thread: totalConstruct 3 totalDestruct 3
|
||||
timerNode: totalConstruct 6 totalDestruct 6
|
||||
timer: totalConstruct 3 totalDestruct 3
|
||||
linkedListNode: totalConstruct 18 totalDestruct 18
|
||||
linkedList: totalConstruct 5 totalDestruct 5
|
||||
|
||||
@@ -141,9 +141,15 @@ void testOperators() {
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
char *fileName = 0;
|
||||
if(argc>1) fileName = argv[1];
|
||||
FILE * fd = stdout;
|
||||
if(fileName!=0 && fileName[0]!=0) {
|
||||
fd = fopen(fileName,"w+");
|
||||
}
|
||||
testGetSetClearFlip();
|
||||
testOperators();
|
||||
//getShowConstructDestruct()->constuctDestructTotals(stdout);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,6 +349,7 @@ static void testTimeLocked(FILE *auxFd) {
|
||||
assert(basicList->isEmpty());
|
||||
delete basicList;
|
||||
for(int i=0; i<numNodes; i++) delete basics[i];
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
typedef std::list<Basic *> stdList;
|
||||
@@ -421,6 +422,7 @@ static void testStdListTimeLocked(FILE *auxFd) {
|
||||
diff = diff/(numNodes*2); // convert to per addTail/removeHead
|
||||
fprintf(auxFd,"time per addTail/removeHead %f microseconds\n",diff);
|
||||
for(int i=0; i<numNodes; i++) delete basics[i];
|
||||
delete mutex;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@@ -446,7 +448,7 @@ int main(int argc, char *argv[]) {
|
||||
testTimeLocked(auxFd);
|
||||
testStdListTime(auxFd);
|
||||
testStdListTimeLocked(auxFd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ static void testBasic(FILE * fd,FILE *auxfd ) {
|
||||
assert(result==false);
|
||||
messageNode = queue->get();
|
||||
assert(messageNode!=0);
|
||||
fprintf(auxfd,"message %s messageType %s\n",
|
||||
fprintf(fd,"message %s messageType %s\n",
|
||||
messageNode->getMessage().c_str(),
|
||||
messageTypeName[messageNode->getMessageType()].c_str());
|
||||
assert(messageNode->getMessage().compare(messages[0])==0);
|
||||
@@ -63,7 +63,7 @@ static void testBasic(FILE * fd,FILE *auxfd ) {
|
||||
queue->release();
|
||||
messageNode = queue->get();
|
||||
assert(messageNode!=0);
|
||||
fprintf(auxfd,"message %s messageType %s\n",
|
||||
fprintf(fd,"message %s messageType %s\n",
|
||||
messageNode->getMessage().c_str(),
|
||||
messageTypeName[messageNode->getMessageType()].c_str());
|
||||
assert(messageNode->getMessage().compare(messages[3])==0);
|
||||
@@ -86,7 +86,7 @@ int main(int argc, char *argv[]) {
|
||||
auxfd = fopen(auxFileName,"w+");
|
||||
}
|
||||
testBasic(fd,auxfd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ int main(int argc, char *argv[]) {
|
||||
auxfd = fopen(auxFileName,"w+");
|
||||
}
|
||||
testBasic(fd,auxfd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,6 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
testBasic(fd);
|
||||
testThreadContext(fd,auxFd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -112,6 +112,6 @@ int main(int argc, char *argv[]) {
|
||||
oneDelay = .0;
|
||||
twoDelay = .0;
|
||||
testBasic(fd,auxfd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ int main(int argc,char *argv[])
|
||||
testDisplay(fd,auxfd);
|
||||
testEnumerated(fd,auxfd);
|
||||
deleteRecords(fd,auxfd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ static void testSimpleStructure(FILE * fd) {
|
||||
|
||||
static StructureConstPtr createPowerSupply() {
|
||||
String properties("alarm");
|
||||
FieldConstPtr powerSupply[3];
|
||||
FieldConstPtrArray powerSupply = new FieldConstPtr[3];
|
||||
powerSupply[0] = standardField->scalar(
|
||||
String("voltage"),pvDouble,properties);
|
||||
powerSupply[1] = standardField->scalar(
|
||||
@@ -129,9 +129,7 @@ static void testStructureArray(FILE * fd) {
|
||||
builder.clear();
|
||||
top->toString(&builder);
|
||||
fprintf(fd,"%s\n",builder.c_str());
|
||||
// create tempory PVField so that memory can be released
|
||||
PVField *pvField = pvDataCreate->createPVField(0,top);
|
||||
delete pvField;
|
||||
top->decReferenceCount();
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[])
|
||||
@@ -149,7 +147,7 @@ int main(int argc,char *argv[])
|
||||
testScalarArray(fd);
|
||||
testSimpleStructure(fd);
|
||||
testStructureArray(fd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ int main(int argc,char *argv[])
|
||||
standardPVField = getStandardPVField();
|
||||
convert = getConvert();
|
||||
testPVAuxInfo(fd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ int main(int argc,char *argv[])
|
||||
testAppend(fd);
|
||||
testPVScalar(fd);
|
||||
testScalarArray(fd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ static String buffer("");
|
||||
|
||||
StructureConstPtr getPowerSupplyStructure() {
|
||||
String properties("alarm");
|
||||
FieldConstPtr powerSupply[3];
|
||||
FieldConstPtrArray powerSupply = new FieldConstPtr[3];
|
||||
powerSupply[0] = standardField->scalar(
|
||||
String("voltage"),pvDouble,properties);
|
||||
powerSupply[1] = standardField->scalar(
|
||||
@@ -49,16 +49,22 @@ void testPowerSupplyArray(FILE * fd) {
|
||||
PVStructureArray * powerSupplyArray =
|
||||
powerSupplyArrayStruct->getStructureArrayField(String("value"));
|
||||
assert(powerSupplyArray!=0);
|
||||
PVStructure *structureArray[3];
|
||||
PVStructurePtrArray structureArray = new PVStructurePtr[3];
|
||||
StructureConstPtr structure =
|
||||
powerSupplyArray->getStructureArray()->getStructure();
|
||||
structure->incReferenceCount();
|
||||
structureArray[0] = pvDataCreate->createPVStructure(0,structure);
|
||||
structure->incReferenceCount();
|
||||
structureArray[1] = pvDataCreate->createPVStructure(0,structure);
|
||||
structure->incReferenceCount();
|
||||
structureArray[2] = pvDataCreate->createPVStructure(0,structure);
|
||||
powerSupplyArray->put(0,3,structureArray,0);
|
||||
buffer.clear();
|
||||
powerSupplyArrayStruct->toString(&buffer);
|
||||
fprintf(fd,"%s\n",buffer.c_str());
|
||||
buffer.clear();
|
||||
powerSupplyArrayStruct->getField()->dumpReferenceCount(&buffer,0);
|
||||
fprintf(fd," reference counts %s\n",buffer.c_str());
|
||||
delete powerSupplyArrayStruct;
|
||||
}
|
||||
|
||||
@@ -75,7 +81,7 @@ int main(int argc,char *argv[])
|
||||
standardField = getStandardField();
|
||||
standardPVField = getStandardPVField();
|
||||
testPowerSupplyArray(fd);
|
||||
getShowConstructDestruct()->constuctDestructTotals(fd);
|
||||
getShowConstructDestruct()->showDeleteStaticExit(fd);
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user