Skip to content

Commit

Permalink
Merge pull request #76 from sveseli/master
Browse files Browse the repository at this point in the history
Resolve monitor overrun issue from PR #75.
  • Loading branch information
anjohnson committed Jun 24, 2022
2 parents 05d54c6 + 0d85561 commit 6cd0a1b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/database/pvRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ PVRecordField::PVRecordField(
PVRecordPtr const & pvRecord)
: pvField(pvField),
isStructure(pvField->getField()->getType()==structure ? true : false),
master(),
parent(parent),
pvRecord(pvRecord)
{
Expand Down Expand Up @@ -420,12 +421,16 @@ void PVRecordField::postParent(PVRecordFieldPtr const & subField)
PVRecordStructurePtr parent(this->parent.lock());
if(parent) {
parent->postParent(subField);
parent->callListener();
}
}

void PVRecordField::postSubField()
{
// Master field pointer will be set in only one subfield
PVRecordStructurePtr master(this->master.lock());
if(master) {
master->callListener();
}
callListener();
if(isStructure) {
PVRecordStructurePtr pvrs =
Expand Down Expand Up @@ -468,6 +473,11 @@ void PVRecordStructure::init()
PVRecordStructurePtr self =
static_pointer_cast<PVRecordStructure>(shared_from_this());
PVRecordPtr pvRecord = getPVRecord();
static bool masterFieldCallbackSet = false;
bool isMasterField = (!getFullFieldName().size());
if (isMasterField) {
masterFieldCallbackSet = false;
}
for(size_t i=0; i<numFields; i++) {
PVFieldPtr pvField = pvFields[i];
if(pvField->getField()->getType()==structure) {
Expand All @@ -481,6 +491,17 @@ void PVRecordStructure::init()
new PVRecordField(pvField,self,pvRecord));
pvRecordFields->push_back(pvRecordField);
pvRecordField->init();
// Master field listeners will be called before
// calling listeners for the first subfield
if (!masterFieldCallbackSet) {
masterFieldCallbackSet = true;
// Find master field
PVRecordStructurePtr p = pvRecordField->parent.lock();
while (p) {
pvRecordField->master = p;
p = p->parent.lock();
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/pv/pvDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ class epicsShareClass PVRecordField :
std::list<PVListenerWPtr> pvListenerList;
epics::pvData::PVField::weak_pointer pvField;
bool isStructure;
PVRecordStructureWPtr master;
PVRecordStructureWPtr parent;
PVRecordWPtr pvRecord;
std::string fullName;
Expand Down

0 comments on commit 6cd0a1b

Please sign in to comment.